Author: shawkins
Date: 2009-04-06 11:32:15 -0400 (Mon, 06 Apr 2009)
New Revision: 719
Added:
trunk/server/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java
Removed:
trunk/client/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java
trunk/common-internal/src/main/java/com/metamatrix/common/config/api/ReleaseInfo.java
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/SessionAdminAPI.java
trunk/console/src/main/java/com/metamatrix/console/ui/views/summary/SummaryConnectionInfo.java
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/SessionAdminAPIImpl.java
Modified:
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java
trunk/client/src/main/java/com/metamatrix/admin/api/objects/Session.java
trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnection.java
trunk/client/src/main/java/com/metamatrix/platform/security/api/ILogon.java
trunk/client/src/main/java/com/metamatrix/platform/security/api/LogonResult.java
trunk/client/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionID.java
trunk/client/src/main/java/com/metamatrix/platform/security/api/SessionToken.java
trunk/client/src/main/java/com/metamatrix/server/serverapi/RequestInfo.java
trunk/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerConnection.java
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/ConfigurationAdminAPI.java
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/RuntimeStateAdminAPI.java
trunk/console/src/main/java/com/metamatrix/console/models/GroupsManager.java
trunk/console/src/main/java/com/metamatrix/console/models/ModelManager.java
trunk/console/src/main/java/com/metamatrix/console/models/QueryManager.java
trunk/console/src/main/java/com/metamatrix/console/models/SessionManager.java
trunk/console/src/main/java/com/metamatrix/console/models/SummaryManager.java
trunk/console/src/main/java/com/metamatrix/console/security/UserCapabilities.java
trunk/console/src/main/java/com/metamatrix/console/ui/views/queries/QueryPanel.java
trunk/console/src/main/java/com/metamatrix/console/ui/views/queries/QueryRequestPanel.java
trunk/console/src/main/java/com/metamatrix/console/ui/views/sessions/SessionPanel.java
trunk/console/src/main/java/com/metamatrix/console/ui/views/summary/SummaryInfoProvider.java
trunk/console/src/main/java/com/metamatrix/console/ui/views/summary/SummaryPanel.java
trunk/embedded/src/main/java/com/metamatrix/jdbc/transport/LocalServerConnection.java
trunk/embedded/src/main/java/com/metamatrix/jdbc/transport/LocalTransportHandler.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
trunk/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java
trunk/engine/src/test/java/com/metamatrix/dqp/service/TestCustomizableTrackingService.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.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/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java
trunk/server/src/main/java/com/metamatrix/admin/server/ServerRuntimeStateAdminImpl.java
trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/LogonImpl.java
trunk/server/src/main/java/com/metamatrix/common/id/dbid/DBIDController.java
trunk/server/src/main/java/com/metamatrix/common/id/dbid/DBIDGenerator.java
trunk/server/src/main/java/com/metamatrix/common/id/dbid/ReservedIDBlock.java
trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/DBIDSourceTransaction.java
trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/InMemoryIDController.java
trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/jdbc/DBIDResourceTransaction.java
trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/jdbc/JDBCNames.java
trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/jdbc/PersistentIDController.java
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/ConfigurationAdminAPIImpl.java
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIImpl.java
trunk/server/src/main/java/com/metamatrix/platform/config/api/service/ConfigurationServiceInterface.java
trunk/server/src/main/java/com/metamatrix/platform/config/service/ConfigurationServiceImpl.java
trunk/server/src/main/java/com/metamatrix/platform/security/api/service/SessionServiceInterface.java
trunk/server/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java
trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java
trunk/server/src/test/java/com/metamatrix/admin/server/TestServerMonitoringAdminImpl.java
trunk/server/src/test/java/com/metamatrix/admin/server/TestServerRuntimeStateAdminImpl.java
trunk/server/src/test/java/com/metamatrix/common/comm/platform/socket/server/TestSocketRemoting.java
trunk/server/src/test/java/com/metamatrix/platform/security/session/service/TestSessionServiceImpl.java
Log:
TEIID-329, TEIID-466, TEIID-467 reverting back to a long session key, but with a hidden
uuid. simplified dbidgenerator, and removed the notion of product specific displays in
the console.
Modified: trunk/client/src/main/java/com/metamatrix/admin/api/objects/Session.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/api/objects/Session.java 2009-04-06
14:29:25 UTC (rev 718)
+++ trunk/client/src/main/java/com/metamatrix/admin/api/objects/Session.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -172,7 +172,7 @@
/**
* Get the IPAddress for this Session
- * @return IPAddress
+ * @return
*/
public String getIPAddress();
@@ -180,9 +180,15 @@
/**
* Get the host name of the machine the client is
* accessing from
- * @return IPAddress
+ * @return
*/
public String getHostName() ;
+
+ /**
+ * Get the time the {@link Session} was created.
+ * @return
+ */
+ public Date getCreatedDate();
}
\ No newline at end of file
Modified:
trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnection.java
===================================================================
---
trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnection.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnection.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -145,7 +145,7 @@
SocketServerInstance instance = connectionFactory.getServerInstance(hostInfo,
secure);
if (this.logonResult != null) {
ILogon newLogon = instance.getService(ILogon.class);
- newLogon.assertIdentity(logonResult.getSessionID());
+ newLogon.assertIdentity(logonResult.getSessionToken());
}
this.serverDiscovery.connectionSuccessful(hostInfo);
this.serverInstance = instance;
Modified: trunk/client/src/main/java/com/metamatrix/platform/security/api/ILogon.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/platform/security/api/ILogon.java 2009-04-06
14:29:25 UTC (rev 718)
+++ trunk/client/src/main/java/com/metamatrix/platform/security/api/ILogon.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -52,6 +52,6 @@
*/
ResultsFuture<?> logoff() throws InvalidSessionException,
MetaMatrixComponentException;
- void assertIdentity(MetaMatrixSessionID sessionId) throws InvalidSessionException,
MetaMatrixComponentException;
+ void assertIdentity(SessionToken sessionId) throws InvalidSessionException,
MetaMatrixComponentException;
}
Modified:
trunk/client/src/main/java/com/metamatrix/platform/security/api/LogonResult.java
===================================================================
---
trunk/client/src/main/java/com/metamatrix/platform/security/api/LogonResult.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/client/src/main/java/com/metamatrix/platform/security/api/LogonResult.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -36,22 +36,19 @@
*/
public class LogonResult implements Serializable {
- private MetaMatrixSessionID sessionID;
private TimeZone timeZone = TimeZone.getDefault();
private final Properties productInfo;
- private String userName;
private String clusterName;
+ private SessionToken sessionToken;
public LogonResult() {
this.productInfo = new Properties();
}
- public LogonResult(MetaMatrixSessionID sessionID,
- String userName, Properties productInfo, String clusterName) {
- this.sessionID = sessionID;
- this.userName = userName;
+ public LogonResult(SessionToken token, Properties productInfo, String clusterName) {
this.productInfo = productInfo;
this.clusterName = clusterName;
+ this.sessionToken = token;
}
/**
@@ -60,7 +57,7 @@
* @since 4.3
*/
public MetaMatrixSessionID getSessionID() {
- return this.sessionID;
+ return this.sessionToken.getSessionID();
}
public TimeZone getTimeZone() {
@@ -72,11 +69,15 @@
}
public String getUserName() {
- return userName;
+ return this.sessionToken.getUsername();
}
public String getClusterName() {
return clusterName;
}
+
+ public SessionToken getSessionToken() {
+ return sessionToken;
+ }
}
Modified:
trunk/client/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionID.java
===================================================================
---
trunk/client/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionID.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/client/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionID.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -23,62 +23,22 @@
package com.metamatrix.platform.security.api;
import java.io.Serializable;
-import java.util.UUID;
/**
- * This immutable class represents an identifier for a unique MetaMatrix session within a
given MetaMatrix System. This object
- * will be returned to the Client when login to the MetaMatrix Server
+ * This immutable class represents an identifier for a unique session.
*/
public final class MetaMatrixSessionID implements
- Serializable,
- Comparable<MetaMatrixSessionID> {
+ Serializable {
public final static long serialVersionUID = -7872739911360962975L;
- private UUID id;
+ private long id;
- /**
- * Used to create a deterministic id, mostly called by tests
- */
public MetaMatrixSessionID(long id) {
- this.id = new UUID(id, id);
+ this.id = id;
}
- public MetaMatrixSessionID() {
- this.id = UUID.randomUUID();
- }
-
/**
- * Converts the given string into a session id.
- * @throws IllegalArgumentException if id is not valid
- * @param id
- */
- public MetaMatrixSessionID(String id) {
- this.id = UUID.fromString(id);
- }
-
- /**
- * Compares this object to another. If the specified object is an instance of the
MetaMatrixSessionID class, then this method
- * compares the contents; otherwise, it throws a ClassCastException (as instances are
comparable only to instances of the same
- * class).
- * <p>
- * Note: this method <i>is </i> consistent with
<code>equals()</code>, meaning that
- * <code>(compare(x, y)==0) == (x.equals(y))</code>.
- * <p>
- *
- * @param obj
- * the object that this instance is to be compared to.
- * @return a negative integer, zero, or a positive integer as this object is less
than, equal to, or greater than the
- * specified object, respectively.
- * @throws NullPointerException
- * if the specified object reference is null
- * @throws ClassCastException
- * if the specified object's type prevents it from being compared to
this instance.
- */
- public int compareTo(MetaMatrixSessionID obj) {
- return this.id.compareTo(obj.id);
- }
- /**
* Returns true if the specified object is semantically equal to this instance. Note:
this method is consistent with
* <code>compareTo()</code>.
*
@@ -96,7 +56,7 @@
// (this includes checking for null ) ...
if (obj instanceof MetaMatrixSessionID) {
MetaMatrixSessionID that = (MetaMatrixSessionID)obj;
- return this.id.equals(that.id);
+ return this.id == that.id;
}
// Otherwise not comparable ...
@@ -109,7 +69,7 @@
* @return a hash code value for this object.
*/
public final int hashCode() {
- return id.hashCode();
+ return (int)id;
}
/**
@@ -118,7 +78,7 @@
* @return the string representation of this instance.
*/
public final String toString() {
- return id.toString();
+ return String.valueOf(id);
}
}
Deleted:
trunk/client/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java
===================================================================
---
trunk/client/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/client/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -1,162 +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.platform.security.api;
-
-import java.io.Serializable;
-import java.util.Properties;
-
-/**
- * This class represents an immutable informational object describing
- * the attributes of a unique MetaMatrix session within a given MetaMatrix System.
- */
-public class MetaMatrixSessionInfo implements Serializable, Cloneable {
-
- public final static long serialVersionUID = -9120197553960136239L;
-
- private SessionToken sessionToken; // immutable
- private long lastPingTime;
- private long timeCreated;
- private String applicationName;
- private String product;
- private Properties productInfo;
- private String clientIp;
- private String clientHostname;
- private Serializable trustedToken;
-
- /**
- * Master constructor, allows a MetaMatrixSessionInfo to be created with
- * any state and any timestamps.
- */
- public MetaMatrixSessionInfo(MetaMatrixSessionID sessionID, String userName, long
timeCreated, String applicationName, Properties productInfo, String product, String
clientIp, String clientHostname){
- this.timeCreated = timeCreated;
- this.lastPingTime = timeCreated;
- this.applicationName = applicationName;
- this.product = product;
- this.sessionToken = new SessionToken(sessionID, userName);
- this.productInfo = productInfo;
- this.clientIp = clientIp;
- this.clientHostname = clientHostname;
- }
-
- public MetaMatrixSessionID getSessionID() {
- return this.sessionToken.getSessionID();
- }
-
- public String getUserName() {
- return this.sessionToken.getUsername();
- }
-
- public String getApplicationName() {
- return this.applicationName;
- }
-
- public long getTimeCreated() {
- return this.timeCreated;
- }
-
- /**
- * Get the time the server was last pinged by this session.
- * Note that the session's "last ping time" will only be acurate
- * if the session is in the ACTIVE state.
- * @return The time the server was last pinged by this session.
- */
- public long getLastPingTime() {
- return lastPingTime;
- }
-
- /**
- * Used <i><b>ONLY</b></i> by the session service to set the
- * time this session last initiated a server ping.
- * @param lastPingTime The last time this session pinged the server.
- */
- public void setLastPingTime(long lastPingTime) {
- this.lastPingTime = lastPingTime;
- }
-
- public String getProductName() {
- return this.product;
- }
-
- public SessionToken getSessionToken(){
- return this.sessionToken;
- }
-
- /**
- * Return a cloned instance of this object.
- * @return the object that is the clone of this instance.
- */
- public Object clone() {
- try {
- // Everything is immutable, so bit-wise copy (of references) is okay!
- return super.clone();
- } catch ( CloneNotSupportedException e ) {
- }
- return null;
- }
-
- /**
- * Returns a string representing the current state of the object.
- */
- public String toString() {
- StringBuffer s = new StringBuffer();
- s.append("MetaMatrixSessionInfo[ "); //$NON-NLS-1$
- s.append(this.sessionToken.toString());
- s.append(", "); //$NON-NLS-1$
- s.append("application:"); //$NON-NLS-1$
- s.append(this.applicationName);
- s.append(", created:"); //$NON-NLS-1$
- s.append(this.timeCreated);
- s.append(", last pinged server:"); //$NON-NLS-1$
- s.append(this.lastPingTime);
- s.append("]"); //$NON-NLS-1$
- return s.toString();
- }
-
- /**
- * @return Returns the productInfo.
- * @since 4.3
- */
- public String getProductInfo(String key) {
- return this.productInfo.getProperty(key);
- }
-
- public Properties getProductInfo() {
- return this.productInfo;
- }
-
- public String getClientIp() {
- return clientIp;
- }
-
- public String getClientHostname() {
- return clientHostname;
- }
-
- public void setTrustedToken(Serializable trustedToken) {
- this.trustedToken = trustedToken;
- }
-
- public Serializable getTrustedToken() {
- return trustedToken;
- }
-}
Modified:
trunk/client/src/main/java/com/metamatrix/platform/security/api/SessionToken.java
===================================================================
---
trunk/client/src/main/java/com/metamatrix/platform/security/api/SessionToken.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/client/src/main/java/com/metamatrix/platform/security/api/SessionToken.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -23,140 +23,138 @@
package com.metamatrix.platform.security.api;
import java.io.Serializable;
+import java.util.UUID;
/**
* This class is an immutable identifier for a unique session that also
- * maintains the name of the principal for that session. It is used internally
- * to MetaMatrix to allow association of a principal name to various activities.
+ * maintains the name of the principal for that session.
*
- * Server-side object should not be returned to the client
+ * Since this class can be used to authenticate a user, it must be secure in
+ * transit if sent to the client. Also it should only be sent to the client
+ * who creates the session.
*/
-public class SessionToken implements Serializable, Comparable<SessionToken>,
Cloneable {
- public final static long serialVersionUID = -2853708320435636107L;
+public class SessionToken implements Serializable,
+ Cloneable {
+ public final static long serialVersionUID = -2853708320435636107L;
- /** The session ID */
- private MetaMatrixSessionID sessionID;
- private String userName;
-
- /**
- * Fake SessionToken representing a trusted user
- */
- public SessionToken() {
- this.sessionID = new MetaMatrixSessionID(-1);
- this.userName = "trusted"; //$NON-NLS-1$
- }
+ /** The session ID */
+ private MetaMatrixSessionID sessionID;
+ private String userName;
+ private UUID secret;
- /**
- * The primary constructor that specifies the id, userName, and product info
- * for the session represented by this token.
- * @param id (long) the unique identifier for the session
- * @param userName (String) the userName for this session
- * @throws IllegalArgumentException
- */
- public SessionToken(MetaMatrixSessionID id, String userName){
- this.sessionID = id;
- this.userName = userName;
- }
+ /**
+ * Fake SessionToken representing a trusted user
+ */
+ public SessionToken() {
+ this.sessionID = new MetaMatrixSessionID(-1);
+ this.userName = "trusted"; //$NON-NLS-1$
+ this.secret = new UUID(1,1);
+ }
- /**
- * Returns unique session identifier
- * @return the session ID
- */
- public MetaMatrixSessionID getSessionID() {
- return this.sessionID;
- }
+ /**
+ * The primary constructor that specifies the id, userName, and product info
+ * for the session represented by this token.
+ *
+ * @param id
+ * (long) the unique identifier for the session
+ * @param userName
+ * (String) the userName for this session
+ * @throws IllegalArgumentException
+ */
+ public SessionToken(MetaMatrixSessionID id, String userName) {
+ this.sessionID = id;
+ this.userName = userName;
+ this.secret = UUID.randomUUID();
+ }
- /**
- * Returns unique session identifier
- * @return the session ID value
- */
- public String getSessionIDValue() {
- return this.sessionID.toString();
- }
+ public UUID getSecret() {
+ return secret;
+ }
- /**
- * Get the principal name for this session's user.
- * @return the user name
- */
- public String getUsername() {
- return this.userName;
- }
-
/**
- * Compares this SessionToken to another Object. If the Object is a SessionToken,
- * this function compares the ID and the user account ID. Otherwise, it throws a
- * ClassCastException (as SessionToken instances are comparable only to
- * other SessionToken instances). Note: this method is consistent with
- * <code>equals()</code>.
- * <p>
- * @param o the object that this instance is to be compared to.
- * @return a negative integer, zero, or a positive integer as this object
- * is less than, equal to, or greater than the specified object, respectively.
- * @throws ClassCastException if the specified object's type prevents it
- * from being compared to this UserID.
+ * Returns unique session identifier
+ *
+ * @return the session ID
*/
- public int compareTo(SessionToken that) {
- if ( that == this ) {
- return 0;
- }
+ public MetaMatrixSessionID getSessionID() {
+ return this.sessionID;
+ }
- // Check if everything else is equal ...
- int result = this.sessionID.compareTo(that.sessionID);
- return result;
- }
+ /**
+ * Returns unique session identifier
+ *
+ * @return the session ID value
+ */
+ public String getSessionIDValue() {
+ return this.sessionID.toString();
+ }
/**
- * Returns true if the specified object is semantically equal to this instance.
- * Note: this method is consistent with <code>compareTo()</code>.
+ * Get the principal name for this session's user.
+ *
+ * @return the user name
+ */
+ public String getUsername() {
+ return this.userName;
+ }
+
+ /**
+ * Returns true if the specified object is semantically equal to this
+ * instance. Note: this method is consistent with <code>compareTo()</code>.
* <p>
- * @param obj the object that this instance is to be compared to.
+ *
+ * @param obj
+ * the object that this instance is to be compared to.
* @return whether the object is equal to this object.
*/
public boolean equals(Object obj) {
- // Check if instances are identical ...
- if (this == obj) {
- return true;
- }
+ // Check if instances are identical ...
+ if (this == obj) {
+ return true;
+ }
- // Check if object can be compared to this one
- // (this includes checking for null ) ...
- if ( obj instanceof SessionToken ) {
- SessionToken that = (SessionToken)obj;
- return ( this.sessionID.equals(that.sessionID) );
- }
+ // Check if object can be compared to this one
+ // (this includes checking for null ) ...
+ if (!(obj instanceof SessionToken)) {
+ return false;
+ }
+ SessionToken that = (SessionToken) obj;
+ return (this.sessionID.equals(that.sessionID))
+ && this.userName.equals(that.userName)
+ && this.secret.equals(that.secret);
+ }
- // Otherwise not comparable ...
- return false;
- }
-
- /**
- * Overrides Object hashCode method.
- * @return a hash code value for this object.
- * @see Object#hashCode()
- * @see Object#equals(Object)
+ /**
+ * Overrides Object hashCode method.
+ *
+ * @return a hash code value for this object.
+ * @see Object#hashCode()
+ * @see Object#equals(Object)
*/
public int hashCode() {
- return this.sessionID.hashCode();
- }
+ return this.sessionID.hashCode();
+ }
- /**
- * Returns a string representing the current state of the object.
- */
- public String toString() {
- return "SessionToken[" + getUsername() + "," +
getSessionIDValue() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
+ /**
+ * Returns a string representing the current state of the object.
+ */
+ public String toString() {
+ return "SessionToken[" + getUsername() + "," + getSessionIDValue()
+ "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
- /**
- * Return a cloned instance of this object.
- * @return the object that is the clone of this instance.
- */
- public Object clone() {
- try {
- // Everything is immutable, so bit-wise copy (of references) is okay!
- return super.clone();
- } catch ( CloneNotSupportedException e ) {
- }
- return null;
- }
+ /**
+ * Return a cloned instance of this object.
+ *
+ * @return the object that is the clone of this instance.
+ */
+ public Object clone() {
+ try {
+ // Everything is immutable, so bit-wise copy (of references) is okay
+ // !
+ return super.clone();
+ } catch (CloneNotSupportedException e) {
+ }
+ return null;
+ }
}
Modified: trunk/client/src/main/java/com/metamatrix/server/serverapi/RequestInfo.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/server/serverapi/RequestInfo.java 2009-04-06
14:29:25 UTC (rev 718)
+++ trunk/client/src/main/java/com/metamatrix/server/serverapi/RequestInfo.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -37,13 +37,14 @@
private RequestID requestID;
private String command;
- private SessionToken token;
private Date submittedTimestamp;
private Date processingTimestamp;
private boolean isSubscription;
private int nodeID = Integer.MIN_VALUE;
private String connectorBindingUUID;
private String transactionId;
+ private String userName;
+ private String sessionId;
public RequestInfo(RequestID requestId, String originalCommand, Date submittedTime,
Date processingTime) {
this.requestID = requestId;
@@ -62,14 +63,6 @@
}
/**
- * Returns the session token that the request was submitted under.
- * @return The session token
- */
- public SessionToken getSessionToken() {
- return this.token;
- }
-
- /**
* Get time that the request was created by the user.
* @return Submitted time in millis.
*/
@@ -122,9 +115,18 @@
* Set the session token that the request was submitted under.
*/
public void setSessionToken(SessionToken token) {
- this.token = token;
+ this.userName = token.getUsername();
+ this.sessionId = token.getSessionIDValue();
}
+ public String getSessionId() {
+ return sessionId;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
/**
* Set the connector binding UUID.
*/
Modified:
trunk/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerConnection.java
===================================================================
---
trunk/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerConnection.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerConnection.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -46,6 +46,7 @@
import com.metamatrix.platform.security.api.ILogon;
import com.metamatrix.platform.security.api.LogonResult;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
+import com.metamatrix.platform.security.api.SessionToken;
/**
* <code>TestCase</case> for <code>SocketServerConnection</code>
@@ -59,10 +60,8 @@
Throwable t;
@Override
- public void assertIdentity(
- MetaMatrixSessionID sessionId)
- throws InvalidSessionException,
- MetaMatrixComponentException {
+ public void assertIdentity(SessionToken sessionId)
+ throws InvalidSessionException, MetaMatrixComponentException {
}
@@ -78,7 +77,7 @@
Properties connectionProperties)
throws LogonException,
MetaMatrixComponentException {
- return new LogonResult(new MetaMatrixSessionID(1), "fooUser", new
Properties(), "fake"); //$NON-NLS-1$ //$NON-NLS-2$
+ return new LogonResult(new SessionToken(new MetaMatrixSessionID(1),
"fooUser"), new Properties(), "fake"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Override
@@ -138,7 +137,7 @@
public void testLogon() throws Exception {
SocketServerConnection connection = createConnection(null);
- assertEquals("00000000-0000-0001-0000-000000000001",
connection.getLogonResult().getSessionID().toString()); //$NON-NLS-1$
+ assertEquals("1", connection.getLogonResult().getSessionID().toString());
//$NON-NLS-1$
}
/**
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java 2009-04-06
14:29:25 UTC (rev 718)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -34,6 +34,7 @@
import com.metamatrix.dqp.client.ClientSideDQP;
import com.metamatrix.platform.security.api.LogonResult;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
+import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.platform.util.ProductInfoConstants;
public class TestMMConnection extends TestCase {
@@ -57,7 +58,7 @@
Properties productInfo = new Properties();
productInfo.setProperty(ProductInfoConstants.VIRTUAL_DB, STD_DATABASE_NAME);
productInfo.setProperty(ProductInfoConstants.VDB_VERSION, STD_DATABASE_VERSION);
- stub(mock.getLogonResult()).toReturn(new LogonResult(new MetaMatrixSessionID(1),
"metamatrixadmin", productInfo, "fake")); //$NON-NLS-1$
+ stub(mock.getLogonResult()).toReturn(new LogonResult(new SessionToken(new
MetaMatrixSessionID(1), "metamatrixadmin"), productInfo, "fake"));
//$NON-NLS-1$
return new MMServerConnection(mock, props, serverUrl);
}
Deleted:
trunk/common-internal/src/main/java/com/metamatrix/common/config/api/ReleaseInfo.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/common/config/api/ReleaseInfo.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/common-internal/src/main/java/com/metamatrix/common/config/api/ReleaseInfo.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -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 com.metamatrix.common.config.api;
-
-import java.io.Serializable;
-
-/**
- * This class is a data holder for release information about a product
- */
-public class ReleaseInfo implements Serializable{
-
- private String name; // name of the product
- private String version; // version of the release
- private String date; // date of the build/release
- private String build; // build number
-
- /**
- * Constructor which sets the various details about release information.
- * @param name of the product.
- * @param version of the release.
- * @param date String build/release date.
- * @param build String build number.
- */
- public ReleaseInfo(String name, String version, String date, String build) {
- this.name = name;
- this.version = version;
- this.date = date;
- this.build = build;
- }
-
- /**
- * This method returns the name of the product.
- * @return product name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * This method returns the version of the product.
- * @return release version.
- */
- public String getVersion() {
- return version;
- }
-
- /**
- * This method returns the build/release date of the product.
- * @return release date
- */
- public String getDate() {
- return date;
- }
-
- /**
- * This method returns the build number of the released product.
- * @return build number of the product.
- */
- public String getBuild() {
- return build;
- }
-
-}
Modified:
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/ConfigurationAdminAPI.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/ConfigurationAdminAPI.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/ConfigurationAdminAPI.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -24,7 +24,6 @@
import java.util.Collection;
import java.util.List;
-import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -44,7 +43,6 @@
import com.metamatrix.common.config.api.Host;
import com.metamatrix.common.config.api.HostID;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
-import com.metamatrix.common.config.api.exceptions.InvalidConfigurationException;
public interface ConfigurationAdminAPI extends SubSystemAdminAPI {
@@ -316,22 +314,5 @@
List checkPropertiesDecryptable(List defns)
throws ConfigurationException, InvalidSessionException, AuthorizationException,
MetaMatrixComponentException;
-
-
- /**
- * Obtain the Collection of {@link com.metamatrix.common.config.api.ReleaseInfo}
objects
- * which represent the products of the system. Each ReleaseInfo contains
- * the name of the product, as well as release info.
- * @return Collection of ReleaseInfo objects containing names of licensed
- * products, as well as other release info
- * @throws AuthorizationException if caller is not authorized to perform this
method.
- * @throws InvalidSessionException if the <code>callerSessionID</code> is
not valid or is expired.
- * @throws MetaMatrixComponentException if an error occurs in communicating with a
component.
- */
- public abstract Collection getProducts() throws AuthorizationException,
- InvalidSessionException,
- MetaMatrixComponentException;
-
-
}
Modified:
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/RuntimeStateAdminAPI.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/RuntimeStateAdminAPI.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/RuntimeStateAdminAPI.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -128,22 +128,6 @@
MetaMatrixComponentException;
/**
- * Shutdown server and restart.
- *
- * @param callerSessionID
- * ID of the caller's current session.
- * @throws AuthorizationException
- * if caller is not authorized to perform this method.
- * @throws InvalidSessionException
- * if the <code>callerSessionID</code> is not valid or is
expired.
- * @throws MetaMatrixComponentException
- * if an error occurred in communicating with a component.
- */
- void bounceServer() throws AuthorizationException,
- InvalidSessionException,
- MetaMatrixComponentException;
-
- /**
* Return the running state of the system.
*
* @return SysteState object that represents the system.
Deleted:
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/SessionAdminAPI.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/SessionAdminAPI.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/SessionAdminAPI.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -1,82 +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.platform.admin.api;
-
-import java.util.Collection;
-
-import com.metamatrix.admin.api.exception.security.InvalidSessionException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.security.AuthorizationException;
-import com.metamatrix.api.exception.security.SessionServiceException;
-
-import com.metamatrix.platform.security.api.MetaMatrixPrincipal;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-
-public interface SessionAdminAPI extends SubSystemAdminAPI {
-
- /**
- * Get the information for the account to which the specified session has been
authenticated.
- *
- * @param userSessionID ID identifying session for which the account information is
to be obtained
- * @return the information for the user account for which the
<code>sessionToken</code> is logged into
- * @throws InvalidSessionException If the caller's session has expired or
doesn't exist
- * @throws SessionNotFoundException If specified
<code>userSessionID</code> is invalid or nonexistant
- * @throws AuthorizationException if the caller denoted by
<code>callerSessionID</code>
- * does not have authority to access the account information for the
<code>userSessionID</code> session
- * @throws MetaMatrixComponentException If couldn't find a component
- */
- MetaMatrixPrincipal getPrincipal(MetaMatrixSessionID userSessionID)
- throws InvalidSessionException, AuthorizationException, MetaMatrixComponentException,
SessionServiceException;
-
- /**
- * Get the collection of active user sessions on the system.
- * @return The collection of MetaMatrixSessionInfo objects of active users on
- * the system - possibly empty, never null.
- */
- Collection getActiveSessions()
- throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException,
SessionServiceException;
-
- /**
- * Get the count of active user sessions on the system.
- * @return The count of all active users on
- * the system.
- */
- int getActiveSessionsCount()
- throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException,
SessionServiceException;
-
- /**
- * Get the count of all active connections to a product.
- * @return The count of all active connections to a product on
- * the system.
- */
- int getActiveConnectionsCountForProduct(String product)
- throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException,
SessionServiceException;
-
- void terminateSession(MetaMatrixSessionID userSessionID)
- throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException,
SessionServiceException;
-
- Boolean isSessionValid(MetaMatrixSessionID userSessionID)
- throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException,
SessionServiceException;
-
-}
-
Modified: trunk/console/src/main/java/com/metamatrix/console/models/GroupsManager.java
===================================================================
---
trunk/console/src/main/java/com/metamatrix/console/models/GroupsManager.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/console/src/main/java/com/metamatrix/console/models/GroupsManager.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -41,7 +41,6 @@
import com.metamatrix.console.ui.views.users.RoleDisplay;
import com.metamatrix.console.util.ExternalException;
import com.metamatrix.platform.admin.api.AuthorizationAdminAPI;
-import com.metamatrix.platform.security.api.MetaMatrixPrincipal;
import com.metamatrix.platform.security.api.MetaMatrixPrincipalName;
public class GroupsManager extends Manager {
@@ -205,10 +204,10 @@
* @return array of RoleDisplays for the provided principal
*/
public RoleDisplay[] getRolesForPrincipal(
- MetaMatrixPrincipal principal, boolean includeImplicit)
+ MetaMatrixPrincipalName principal, boolean includeImplicit)
throws ComponentNotFoundException, AuthorizationException,
ExternalException, MetaMatrixSecurityException {
- return getRolesForPrincipal(principal.getMetaMatrixPrincipalName());
+ return getRolesForPrincipal(principal);
}
/**
Modified: trunk/console/src/main/java/com/metamatrix/console/models/ModelManager.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/models/ModelManager.java 2009-04-06
14:29:25 UTC (rev 718)
+++ trunk/console/src/main/java/com/metamatrix/console/models/ModelManager.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -42,7 +42,6 @@
import com.metamatrix.platform.admin.api.ExtensionSourceAdminAPI;
import com.metamatrix.platform.admin.api.MembershipAdminAPI;
import com.metamatrix.platform.admin.api.RuntimeStateAdminAPI;
-import com.metamatrix.platform.admin.api.SessionAdminAPI;
import com.metamatrix.platform.admin.api.SubSystemAdminAPI;
import com.metamatrix.platform.security.api.MetaMatrixPrincipalName;
import com.metamatrix.server.admin.api.QueryAdminAPI;
@@ -332,11 +331,6 @@
return (RuntimeStateAdminAPI) getSubSystemAdminAPI(RuntimeStateAdminAPI.class,
conn);
}
- public static SessionAdminAPI getSessionAPI(ConnectionInfo conn) {
-
- return (SessionAdminAPI) getSubSystemAdminAPI(SessionAdminAPI.class, conn);
- }
-
public static QueryAdminAPI getQueryAPI(ConnectionInfo conn) {
return (QueryAdminAPI) getSubSystemAdminAPI(QueryAdminAPI.class, conn);
Modified: trunk/console/src/main/java/com/metamatrix/console/models/QueryManager.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/models/QueryManager.java 2009-04-06
14:29:25 UTC (rev 718)
+++ trunk/console/src/main/java/com/metamatrix/console/models/QueryManager.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -34,17 +34,12 @@
import com.metamatrix.api.exception.ComponentNotFoundException;
import com.metamatrix.api.exception.security.AuthorizationException;
import com.metamatrix.api.exception.server.InvalidRequestIDException;
-
import com.metamatrix.console.connections.ConnectionInfo;
import com.metamatrix.console.ui.ViewManager;
import com.metamatrix.console.util.AutoRefresher;
import com.metamatrix.console.util.ExternalException;
import com.metamatrix.console.util.InvalidRequestException;
-
-import com.metamatrix.platform.admin.api.SessionAdminAPI;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
-
import com.metamatrix.server.admin.api.QueryAdminAPI;
import com.metamatrix.server.serverapi.RequestInfo;
@@ -72,10 +67,6 @@
return ModelManager.getQueryAPI(getConnection());
}
- private SessionAdminAPI getSessionAdminAPI() {
- return ModelManager.getSessionAPI(getConnection());
- }
-
/**
* The QueryManager listens for changes to the SessionManager. If, for
*example, a session is terminated, the QueryManager needs to know so
@@ -164,14 +155,6 @@
return (Collection) getQueryRequests().clone();
}
- public Collection getRequestsForSession(MetaMatrixSessionInfo session)
- throws AuthorizationException, ExternalException {
- Collection result;
- loadRealData(session.getSessionToken().getSessionID());
- result = (Collection) getQueryRequests().clone();
- return result;
- }
-
public void setAutoRefresher(AutoRefresher autoRefresher){
ar = autoRefresher;
}
@@ -205,46 +188,6 @@
}
}
- /**
- * TODO: Need to fix this to only load query data for a given session,
- *but to know when queries for a DIFFERENT session are requested.
- *Currently, this just loads ALL active queries - i.e. calls loadRealData()
- */
- private void loadRealData(MetaMatrixSessionID token)
- throws ExternalException, AuthorizationException {
- Collection col = null;
- if (getIsStale() || !token.equals(currentToken)){
- try{
- currentToken = token;
- ViewManager.startBusy(); //ADJUSTS STATUS BAR
-
- //THIS COULD FAIL SILENTLY
-
- if (getSessionAdminAPI().isSessionValid(token).booleanValue()){
- col = getQueryAdminAPI().getRequestsForSession(token);
- }
- else{
- //Session ID: "+token.getValue()+" is invalid");
- }
-
- if (col!= null)
- setQueryRequests(new HashSet(col));
- else
- setQueryRequests(new HashSet(0));
- setIsStale(false);
- super.startTimer();
- } catch (InvalidSessionException e) {
- setQueryRequests(new HashSet(0));
- } catch (AuthorizationException e) {
- throw e;
- } catch (Exception e) {
- throw new ExternalException(e);
- } finally {
- ViewManager.endBusy();
- }
- }
- }
-
//GETTERS-SETTERS
private HashSet getQueryRequests(){
Modified: trunk/console/src/main/java/com/metamatrix/console/models/SessionManager.java
===================================================================
---
trunk/console/src/main/java/com/metamatrix/console/models/SessionManager.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/console/src/main/java/com/metamatrix/console/models/SessionManager.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -24,16 +24,12 @@
import java.util.Collection;
-import com.metamatrix.api.exception.ComponentNotFoundException;
-import com.metamatrix.api.exception.security.AuthorizationException;
-
+import com.metamatrix.admin.api.objects.Session;
import com.metamatrix.console.connections.ConnectionInfo;
import com.metamatrix.console.ui.ViewManager;
import com.metamatrix.console.util.ExternalException;
+import com.metamatrix.platform.security.api.ILogon;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
-
/**
* Facade for GUI client to Session objects and Session-related functionality
*of the remote system. SessionManager maintains a collection of
@@ -49,6 +45,9 @@
* @see SessionManager#terminateSession
*/
public static final String SESSION_TERMINATED= "A Session was terminated.";
//$NON-NLS-1$
+
+ private Collection<Session> sessions;
+ private long lastReferesh;
public SessionManager(ConnectionInfo connection) {
super(connection);
@@ -66,58 +65,48 @@
super.setIsAutoRefreshEnabled(false);
}
- public Collection /*<MetaMatrixSessionInfo >*/ getActiveSessions() throws
Exception {
- Collection result = null;
- result = ModelManager.getSessionAPI(getConnection()).getActiveSessions();
- return result;
- }
-
/**
* Terminates, on remote system, the session specified by the parameter.
*Fires a ModelChangedEvent with message
*SessionManager.TERMINATE_SESSION and arg SessionToken.
* @param userSessionInfo identifies session to be terminated
*/
- public void terminateSession(MetaMatrixSessionInfo userSessionInfo)
- throws ExternalException, AuthorizationException,
- ComponentNotFoundException {
+ public void terminateSession(String userSessionInfo)
+ throws ExternalException {
try {
ViewManager.startBusy(); //ADJUSTS STATUS BAR
- ModelManager.getSessionAPI(getConnection()).terminateSession(
- userSessionInfo.getSessionID());
- } catch (ComponentNotFoundException e) {
- throw e;
- } catch (AuthorizationException e) {
- throw e;
+ getConnection().getServerAdmin().terminateSession(userSessionInfo);
} catch (Exception e) {
throw new ExternalException(e);
} finally {
ViewManager.endBusy(); //ADJUSTS STATUS BAR
}
- super.fireModelChangedEvent(SESSION_TERMINATED,
userSessionInfo.getSessionToken());
+ super.fireModelChangedEvent(SESSION_TERMINATED, userSessionInfo);
}
- public Collection /*<MetaMatrixSessionInfo>*/ getSessions() throws Exception {
- return getActiveSessions();
+ public Collection<Session> getSessions() throws Exception {
+ return getSessions(false);
}
+
+ public Collection<Session> getSessions(boolean refresh) throws Exception {
+ if (refresh || lastReferesh + 30000 < System.currentTimeMillis()) {
+ this.sessions = getConnection().getServerAdmin().getSessions("*");
//$NON-NLS-1$
+ }
+ return this.sessions;
+ }
public boolean isSignedOnUserSessionValid() {
- Boolean BIsValid = Boolean.FALSE;
try {
ViewManager.startBusy(); //ADJUSTS STATUS BAR
- MetaMatrixSessionID mmsidSessionID
- =
getConnection().getServerConnection().getLogonResult().getSessionID();
-
- BIsValid = ModelManager.getSessionAPI(getConnection())
- .isSessionValid( mmsidSessionID );
-
+ getConnection().getServerConnection().getService(ILogon.class).ping();
+ return true;
} catch (Exception e) {
// no action, exception interpreted as FALSE
} finally {
ViewManager.endBusy(); //ADJUSTS STATUS BAR
}
- return BIsValid.booleanValue();
+ return false;
}
}
Modified: trunk/console/src/main/java/com/metamatrix/console/models/SummaryManager.java
===================================================================
---
trunk/console/src/main/java/com/metamatrix/console/models/SummaryManager.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/console/src/main/java/com/metamatrix/console/models/SummaryManager.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -26,23 +26,18 @@
* All Rights Reserved.
*/
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
-import com.metamatrix.api.exception.security.AuthorizationException;
+import com.metamatrix.admin.api.objects.Session;
import com.metamatrix.common.config.api.Host;
import com.metamatrix.common.config.api.HostID;
-import com.metamatrix.common.config.api.ReleaseInfo;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.MetaMatrixProductNames;
import com.metamatrix.console.connections.ConnectionInfo;
-import com.metamatrix.console.ui.views.summary.SummaryConnectionInfo;
import com.metamatrix.console.ui.views.summary.SummaryHostInfo;
import com.metamatrix.console.ui.views.summary.SummaryInfoProvider;
-import com.metamatrix.console.util.ExternalException;
import com.metamatrix.console.util.LogContexts;
import com.metamatrix.platform.admin.api.RuntimeStateAdminAPI;
import com.metamatrix.platform.admin.api.runtime.HostData;
@@ -65,7 +60,7 @@
super.init();
}
- public String getSysURL() throws ExternalException{
+ public String getSysURL() {
return getConnection().getURL();
}
@@ -100,8 +95,7 @@
}
public int getActiveSessionCount() throws Exception {
- return ModelManager.getSessionAPI(getConnection())
- .getActiveSessionsCount();
+ return
ModelManager.getSessionManager(this.getConnection()).getSessions().size();
}
public SummaryHostInfo[] getHostInfo() throws Exception {
@@ -123,43 +117,6 @@
return info;
}
- public SummaryConnectionInfo[] getConnectionInfo() throws Exception {
- Collection /*<ReleaseInfo>*/ products =
- ModelManager.getConfigurationAPI(getConnection()).getProducts();
- Collection /*<SummaryConnectionInfo>*/ sum = new ArrayList(5);
- Iterator it = products.iterator();
- while (it.hasNext()) {
- ReleaseInfo ri = (ReleaseInfo)it.next();
- String productName = ri.getName();
- if (!(productName.equals(MetaMatrixProductNames.Platform.PRODUCT_NAME) ||
-
productName.equals(MetaMatrixProductNames.ConnectorProduct.PRODUCT_NAME))) {
- SummaryConnectionInfo sci = new SummaryConnectionInfo(productName,
- ModelManager.getSessionAPI(getConnection())
- .getActiveConnectionsCountForProduct(productName));
- sum.add(sci);
- }
- }
- SummaryConnectionInfo[] summaryInfo = new SummaryConnectionInfo[sum.size()];
- it = sum.iterator();
- for (int i = 0; it.hasNext(); i++) {
- summaryInfo[i] = (SummaryConnectionInfo)it.next();
- }
- return summaryInfo;
- }
-
- public Collection getHostName() throws AuthorizationException,
- ExternalException{
- Collection hostList = null;
- try {
- hostList = getHosts();
- } catch (AuthorizationException e) {
- throw(e);
- } catch (Exception e) {
- throw new ExternalException(e);
- }
- return hostList;
- }
-
public Collection getHosts() throws Exception {
Collection hosts = new HashSet();
Iterator itDeployedHostIDs = ModelManager.getConfigurationAPI(
@@ -176,17 +133,6 @@
return hosts;
}
- public ReleaseInfo[] getProductReleaseInfo() throws Exception {
- Collection /*<ReleaseInfo>*/ products =
- ModelManager.getConfigurationAPI(getConnection()).getProducts();
- ReleaseInfo[] ri = new ReleaseInfo[products.size()];
- Iterator it = products.iterator();
- for (int i = 0; it.hasNext(); i++) {
- ri[i] = (ReleaseInfo)it.next();
- }
- return ri;
- }
-
/******************************
/ Private internal methods
******************************/
@@ -216,4 +162,17 @@
}
return status;
}
+
+ @Override
+ public Date getLastSessionStartUp() throws Exception {
+ Collection<Session> sessions =
ModelManager.getSessionManager(this.getConnection()).getSessions();
+ Date start = null;
+ for (Session session : sessions) {
+ Date createDate = session.getCreatedDate();
+ if (start == null || start.compareTo(createDate) > 0) {
+ start = createDate;
+ }
+ }
+ return start;
+ }
}
Modified:
trunk/console/src/main/java/com/metamatrix/console/security/UserCapabilities.java
===================================================================
---
trunk/console/src/main/java/com/metamatrix/console/security/UserCapabilities.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/console/src/main/java/com/metamatrix/console/security/UserCapabilities.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -37,7 +37,6 @@
import com.metamatrix.console.util.ExternalException;
import com.metamatrix.platform.security.api.MetaMatrixPrincipal;
import com.metamatrix.platform.security.api.MetaMatrixPrincipalName;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
/**
* This is a singleton for accessing user capabilities.
@@ -113,16 +112,8 @@
boolean systemAdminMMS = false;
boolean viewOnly = false;
- // 1. Get the Session ID
- MetaMatrixSessionID mmsidSessionID = conn.getSessionID();
- // 2. Get the principal
- MetaMatrixPrincipal mmpPrincipal =
ModelManager.getSessionAPI(conn).getPrincipal(
- mmsidSessionID);
+ RoleDisplay[] rd =
ModelManager.getGroupsManager(conn).getRolesForPrincipal(getLoggedInUser(conn), true);
- // 3. Get this Principal's Roles
- RoleDisplay[] rd = ModelManager.getGroupsManager(conn).getRolesForPrincipal(
- mmpPrincipal, true);
-
// From the roles set the Role booleans
for (int i = 0; i < rd.length; i++) {
String sRole = rd[i].getName();
@@ -322,13 +313,8 @@
}
public static MetaMatrixPrincipalName getLoggedInUser(
- ConnectionInfo connection) throws Exception {
- MetaMatrixSessionID mmsidSessionID =
- connection.getSessionID();
- MetaMatrixPrincipal mmpPrincipal = ModelManager.getSessionAPI(
- connection).getPrincipal(mmsidSessionID);
- MetaMatrixPrincipalName loggedInUser =
- mmpPrincipal.getMetaMatrixPrincipalName();
+ ConnectionInfo connection) {
+ MetaMatrixPrincipalName loggedInUser = new
MetaMatrixPrincipalName(connection.getServerConnection().getLogonResult().getUserName(),
MetaMatrixPrincipal.TYPE_ADMIN);
return loggedInUser;
}
}
Modified:
trunk/console/src/main/java/com/metamatrix/console/ui/views/queries/QueryPanel.java
===================================================================
---
trunk/console/src/main/java/com/metamatrix/console/ui/views/queries/QueryPanel.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/console/src/main/java/com/metamatrix/console/ui/views/queries/QueryPanel.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -63,7 +63,6 @@
import com.metamatrix.console.util.StaticProperties;
import com.metamatrix.console.util.StaticUtilities;
import com.metamatrix.core.util.StringUtil;
-import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.server.serverapi.RequestInfo;
import com.metamatrix.toolbox.ui.widget.LabelWidget;
import com.metamatrix.toolbox.ui.widget.Splitter;
@@ -303,21 +302,14 @@
public void displayQuery(RequestInfo request) {
if (request != null) {
txfRequestId.setText(String.valueOf(request.getRequestID()));
- SessionToken sessionToken = request.getSessionToken();
- String sessionIDStr = StringUtil.Constants.EMPTY_STRING;
- if (sessionToken != null) {
- sessionIDStr = sessionToken.getSessionIDValue();
- }
+ String sessionIDStr = request.getSessionId();
txfSessionId.setText(sessionIDStr);
Date date = request.getProcessingTimestamp();
txfSubmitted.setText((date == null) ? StringUtil.Constants.EMPTY_STRING :
FORMATTER.format(date));
String transId = request.getTransactionId();
txfTransactionId.setText((transId == null) ? StringUtil.Constants.EMPTY_STRING :
transId);
- String userStr = StringUtil.Constants.EMPTY_STRING;
- if (sessionToken != null) {
- userStr = sessionToken.getUsername();
- }
+ String userStr = request.getUserName();
txfUser.setText(userStr);
String bindingUUID = request.getConnectorBindingUUID();
Modified:
trunk/console/src/main/java/com/metamatrix/console/ui/views/queries/QueryRequestPanel.java
===================================================================
---
trunk/console/src/main/java/com/metamatrix/console/ui/views/queries/QueryRequestPanel.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/console/src/main/java/com/metamatrix/console/ui/views/queries/QueryRequestPanel.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -57,7 +57,6 @@
import com.metamatrix.console.util.ExternalException;
import com.metamatrix.console.util.StaticUtilities;
import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.server.serverapi.RequestInfo;
import com.metamatrix.toolbox.ui.widget.DialogPanel;
import com.metamatrix.toolbox.ui.widget.DialogWindow;
@@ -268,11 +267,8 @@
String requestStr = getRequestInfoDisplayString(q);
rowData[QueryTableModel.REQUEST_ID_COL] = requestStr;
tempRequestsMap.put(requestStr, q);
- SessionToken st = q.getSessionToken();
- if (st != null) {
- rowData[QueryTableModel.USER_COL] = st.getUsername();
- rowData[QueryTableModel.SESSION_ID_COL] = st.getSessionIDValue();
- }
+ rowData[QueryTableModel.USER_COL] = q.getUserName();
+ rowData[QueryTableModel.SESSION_ID_COL] = q.getSessionId();
rowData[QueryTableModel.CONNECTOR_BINDING_COL] =
getConnectorBindingForUUID(q.getConnectorBindingUUID());
Vector innerVec = StaticUtilities.arrayToVector(rowData);
Modified:
trunk/console/src/main/java/com/metamatrix/console/ui/views/sessions/SessionPanel.java
===================================================================
---
trunk/console/src/main/java/com/metamatrix/console/ui/views/sessions/SessionPanel.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/console/src/main/java/com/metamatrix/console/ui/views/sessions/SessionPanel.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -35,8 +35,8 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Date;
import java.util.Iterator;
+import java.util.List;
import javax.swing.AbstractAction;
import javax.swing.Action;
@@ -51,6 +51,7 @@
import javax.swing.event.ListSelectionListener;
import javax.swing.table.TableColumn;
+import com.metamatrix.admin.api.objects.Session;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.console.ConsolePlugin;
import com.metamatrix.console.connections.ConnectionInfo;
@@ -75,8 +76,6 @@
import com.metamatrix.console.util.StaticProperties;
import com.metamatrix.console.util.StaticUtilities;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
-import com.metamatrix.platform.util.ProductInfoConstants;
import com.metamatrix.toolbox.ui.widget.TableWidget;
import com.metamatrix.toolbox.ui.widget.table.EnhancedTableColumn;
@@ -132,7 +131,7 @@
private AutoRefresher arRefresher = null;
//the original universe of current sessions
- private java.util.List /*<MetaMatrixSessionInfo>*/ allSessions;
+ private List<Session> allSessions;
private boolean programaticSelectionChange = false;
@@ -373,25 +372,21 @@
}
private Object[][] getSessionData() {
- Iterator iterator = allSessions.iterator();
Object[][] data = new Object[allSessions.size()][SessionTableModel.COLUMN_COUNT];
// Populate the table data.
- MetaMatrixSessionInfo u;
- for (int i=0; iterator.hasNext(); i++){
- u = (MetaMatrixSessionInfo)iterator.next();
+ for (int i=0; i < allSessions.size(); i++){
+ Session u = allSessions.get(i);
//match these up with column names
data[i][SessionTableModel.SESSION_ID_COLUMN_NUM] = u.getSessionID().toString();
data[i][SessionTableModel.USER_NAME_COLUMN_NUM] = u.getUserName();
data[i][SessionTableModel.APPLICATION_COLUMN_NUM] = u.getApplicationName();
- data[i][SessionTableModel.LOGGED_IN_COLUMN_NUM] = new Date(u.getTimeCreated());
- data[i][SessionTableModel.LAST_PING_TIME] = new Date(u.getLastPingTime());
- String vdbName = u.getProductInfo(
- ProductInfoConstants.VIRTUAL_DB);
+ data[i][SessionTableModel.LOGGED_IN_COLUMN_NUM] = u.getCreatedDate();
+ data[i][SessionTableModel.LAST_PING_TIME] = u.getLastPingTime();
+ String vdbName = u.getVDBName();
data[i][SessionTableModel.VDB_NAME_COLUMN_NUM] =
(vdbName!=null?vdbName:"");//$NON-NLS-1$
- String vdbVersStr = u.getProductInfo(
- ProductInfoConstants.VDB_VERSION);
+ String vdbVersStr = u.getVDBVersion();
if (vdbVersStr != null) {
vdbVersStr = vdbVersStr.trim();
} else {
@@ -433,11 +428,8 @@
ListSelectionModel lsm = sessionTable.getSelectionModel();
for (int i = lsm.getMinSelectionIndex(); i <= lsm.getMaxSelectionIndex();
i++){
if (lsm.isSelectedIndex(i)){
- MetaMatrixSessionInfo sessInfo;
- int modelIndex;
-
- modelIndex = sessionTable.convertRowIndexToModel(i);
- sessInfo = (MetaMatrixSessionInfo)allSessions.get(modelIndex);
+ int modelIndex = sessionTable.convertRowIndexToModel(i);
+ Session sessInfo = allSessions.get(modelIndex);
result.add(new SessionInfoIndexPair(sessInfo,modelIndex));
}
}
@@ -482,7 +474,7 @@
} else {
int tableRow = sessionTable.getSelectedRow();
int modelRow = sessionTable.convertRowIndexToModel(tableRow);
- MetaMatrixSessionInfo sessToKill = (MetaMatrixSessionInfo)
allSessions.get(modelRow);
+ Session sessToKill = allSessions.get(modelRow);
String session = sessToKill.toString(); //$NON-NLS-1$
confirmed = DialogUtility.yesNoDialog(null,
ConsolePlugin.Util.getString("SessionPanel.Terminate_Session__23") + session +
"?", //$NON-NLS-1$ //$NON-NLS-2$
@@ -498,11 +490,11 @@
try {
while (it.hasNext()) {
SessionInfoIndexPair pair = (SessionInfoIndexPair)it.next();
- MetaMatrixSessionInfo sessInfo = pair.sessInfo;
+ Session sessInfo = pair.sessInfo;
int modelIndex =pair.modelIndex;
- MetaMatrixSessionID id = sessInfo.getSessionID();
- if (!id.equals(connection.getSessionID())) {
- getSessionManager().terminateSession(sessInfo);
+ String id = sessInfo.getSessionID();
+ if (!id.equals(connection.getSessionID().toString())) {
+ getSessionManager().terminateSession(id);
//Sanity check here- our index and sessinfo should still mesh
//once we terminate it, we should yank it from the model and
display
@@ -535,9 +527,9 @@
*/
public void refreshTable() {
boolean continuing = true;
- Collection /*<MetaMatrixSessionInfo>*/ sessions = null;
+ Collection<Session> sessions = null;
try {
- sessions = getSessionManager().getSessions();
+ sessions = getSessionManager().getSessions(true);
} catch (Exception ex) {
LogManager.logError(LogContexts.SESSIONS, ex,
ConsolePlugin.Util.getString("SessionPanel.Error_retrieving_sessions_information_28"));
//$NON-NLS-1$
ExceptionUtility.showMessage(ConsolePlugin.Util.getString("SessionPanel.Error_retrieving_session_information_29"),
//$NON-NLS-1$
@@ -573,12 +565,12 @@
}
while (iter.hasNext()) {
SessionInfoIndexPair pair = (SessionInfoIndexPair)iter.next();
- MetaMatrixSessionInfo sessInfo = pair.sessInfo;
- MetaMatrixSessionID id = sessInfo.getSessionID();
+ Session sessInfo = pair.sessInfo;
+ String id = sessInfo.getSessionID();
int rowCount = sessionTable.getRowCount();
for (int i = 0; i < rowCount ; i++){
String rowId =
(String)sessionTable.getValueAt(i,SessionTableModel.SESSION_ID_COLUMN_NUM);
- if (id.toString().equals(rowId)){
+ if (id.equals(rowId)){
sessionTable.addRowSelectionInterval(i,i);
}
@@ -698,10 +690,10 @@
class SessionInfoIndexPair implements Comparable{
- public MetaMatrixSessionInfo sessInfo;
+ public Session sessInfo;
public int modelIndex;
- public SessionInfoIndexPair(MetaMatrixSessionInfo sessInfo, int modelIndex){
+ public SessionInfoIndexPair(Session sessInfo, int modelIndex){
this.sessInfo=sessInfo;
this.modelIndex=modelIndex;
}
Deleted:
trunk/console/src/main/java/com/metamatrix/console/ui/views/summary/SummaryConnectionInfo.java
===================================================================
---
trunk/console/src/main/java/com/metamatrix/console/ui/views/summary/SummaryConnectionInfo.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/console/src/main/java/com/metamatrix/console/ui/views/summary/SummaryConnectionInfo.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -1,44 +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.console.ui.views.summary;
-
-public class SummaryConnectionInfo {
-
- private String productName;
- private int currentCount;
-
-
- public SummaryConnectionInfo(String productName, int currentCount){
- this.productName = productName;
- this.currentCount = currentCount;
- }
-
- public String getProductName(){
- return productName;
- }
-
- public int getCurrentCount(){
- return currentCount;
- }
-
-}
Modified:
trunk/console/src/main/java/com/metamatrix/console/ui/views/summary/SummaryInfoProvider.java
===================================================================
---
trunk/console/src/main/java/com/metamatrix/console/ui/views/summary/SummaryInfoProvider.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/console/src/main/java/com/metamatrix/console/ui/views/summary/SummaryInfoProvider.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -24,8 +24,6 @@
import java.util.Date;
-import com.metamatrix.common.config.api.ReleaseInfo;
-
public interface SummaryInfoProvider {
public final static int GREEN = 1;
public final static int YELLOW = 2;
@@ -37,6 +35,5 @@
Date getSystemStartUpTime() throws Exception;
int getActiveSessionCount() throws Exception;
SummaryHostInfo[] getHostInfo() throws Exception;
- SummaryConnectionInfo[] getConnectionInfo() throws Exception;
- ReleaseInfo[] getProductReleaseInfo() throws Exception;
+ Date getLastSessionStartUp() throws Exception;
}
Modified:
trunk/console/src/main/java/com/metamatrix/console/ui/views/summary/SummaryPanel.java
===================================================================
---
trunk/console/src/main/java/com/metamatrix/console/ui/views/summary/SummaryPanel.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/console/src/main/java/com/metamatrix/console/ui/views/summary/SummaryPanel.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -76,21 +76,18 @@
private String sysURL;
private String sysName;
private int activeSessionCount, systemState;
- private Date startTime;
+ private Date lastSessionStart, startTime;
private SummaryHostInfo[] hostInfo;
- private SummaryConnectionInfo[] connectionInfo;
private JPanel hostPanel;
private JPanel sessionsPanel;
- private JPanel connectionsPanel;
private JPanel systemStatePanel;
private TextFieldWidget runningTFW;
private TextFieldWidget startTimeTFW;
private LabelWidget runJL;
private LabelWidget startedJL;
private TextFieldWidget activeSessionCountTFW;
- private TableWidget connectionsTable;
+ private TextFieldWidget lastSessionTFW;
private JPanel stopLightPanel;
- private String[] connectionsTableColumns = {"Product",
"Connections"};
private TableWidget hostTable;
private String[] hostTableColumns = {"Host Identifier",
"Status"};
private GridBagLayout sysStateLayout;
@@ -223,12 +220,6 @@
tBorder.setTitleFont(tBorder.getTitleFont().deriveFont(Font.BOLD));
sessionsPanel.setBorder(tBorder);
- connectionsPanel = buildConnectionsPanel();
- tBorder = new TitledBorder("Connections");
- tBorder.setTitleJustification(TitledBorder.LEFT);
- tBorder.setTitleFont(tBorder.getTitleFont().deriveFont(Font.BOLD));
- connectionsPanel.setBorder(tBorder);
-
ButtonWidget refreshButton = new ButtonWidget("Refresh");
refreshButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
@@ -247,7 +238,6 @@
JPanel lowerBoxPanel = new JPanel();
lowerBoxPanel.setLayout(new GridLayout(1, 2, 10, 0));
lowerBoxPanel.add(hostPanel);
- lowerBoxPanel.add(connectionsPanel);
pnlOuterLayout.setConstraints(upperBoxPanel, new GridBagConstraints(
0, 1, 1, 1, 1, 0, GridBagConstraints.CENTER,
GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0));
@@ -440,6 +430,13 @@
LogManager.logError(LogContexts.SUMMARY, e,
"Error retrieving active session count.");
}
+
+ try {
+ lastSessionStart = summaryInfoProvider.getLastSessionStartUp();
+ } catch (Exception e) {
+ LogManager.logError(LogContexts.SUMMARY, e,
+ "Error retrieving last session start time.");
+ }
}
@@ -472,6 +469,13 @@
activeSessionCountTFW.setEditable(false);
activeSessionCountTFW.setText(""+activeSessionCount);
+ lastSessionTFW = new TextFieldWidget(105);
+ lastSessionTFW.setEditable(false);
+ if (lastSessionStart == null) {
+ lastSessionTFW.setText("");
+ } else {
+ lastSessionTFW.setText(lastSessionStart.toString());
+ }
LabelWidget lastSessionJL = new LabelWidget("Last Logged In:");
lastSessionJL.setName("SummaryPanel.sessionState1");
@@ -489,65 +493,19 @@
1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE,
new Insets(5, 5, 5, 5), 0, 0));
+ sessionLayout.setConstraints(lastSessionTFW , new GridBagConstraints(
+ 1, 1, GridBagConstraints.REMAINDER, 1, 1 , 0,
+ GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
+ new Insets(5, 5, 5, 10), 0, 0));
+
sessionPanel.add(activeSessionCountJL);
sessionPanel.add(activeSessionCountTFW);
sessionPanel.add(lastSessionJL);
+ sessionPanel.add(lastSessionTFW);
return sessionPanel;
}
- private void getConnectionInfo() {
- try {
- connectionInfo = summaryInfoProvider.getConnectionInfo();
- } catch (Exception e) {
- LogManager.logError(LogContexts.SUMMARY, e,
- "Error retrieving current connection information.");
- connectionInfo = null;
- }
- }
-
- private JPanel buildConnectionsPanel() {
- Object[][] data = getConnectionsTableData();
- DefaultTableModel tableModel = new DefaultTableModel(data,
- connectionsTableColumns);
- connectionsTable = new SummaryTableWidget(tableModel);
- connectionsTable.setEditable(false);
- connectionsTable.setName("System Summary connection table");
- JScrollPane scrollPane = new JScrollPane(connectionsTable) {
- public void setBounds(final int x, final int y, final int width, final int
height) {
- super.setBounds(x, y, width, height);
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- connectionsTable.sizeColumnsToFitData();
- }
- });
- }
- };
- JPanel cPanel = new JPanel(new BorderLayout());
- cPanel.add(scrollPane, BorderLayout.CENTER);
- return cPanel;
- }
-
- private Object[][] getConnectionsTableData() {
- Object[][] data;
- if ((connectionInfo == null) || (connectionInfo.length == 0)) {
- data = new Object[1][2];
- data[0][0] ="";
- data[0][1] = "";
- } else {
- data = new Object[connectionInfo.length + 1][2];
- int totalCurrent = 0;
- for (int i = 0; i < connectionInfo.length; i++) {
- data[i][0] = connectionInfo[i].getProductName();
- data[i][1] = new Integer(connectionInfo[i].getCurrentCount());
- totalCurrent += connectionInfo[i].getCurrentCount();
- }
- data[connectionInfo.length][0] = "Total";
- data[connectionInfo.length][1] = new Integer(totalCurrent);
- }
- return data;
- }
-
public void refreshData() {
PanelsTree tree = PanelsTree.getInstance(getConnection());
tree.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
@@ -561,7 +519,6 @@
getSessionInfo();
getSystemStateInfo();
getHostsInfo();
- getConnectionInfo();
JPanel stopLightIcon;
if (systemState == SummaryInfoProvider.GREEN) {
stopLightIcon = GREEN_LIGHT;
@@ -579,16 +536,14 @@
}
activeSessionCountTFW.setText(
(new Integer(activeSessionCount)).toString());
+ if (lastSessionStart != null) {
+ lastSessionTFW.setText(lastSessionStart.toString());
+ }
Object[][] hostData = getHostTableData();
((DefaultTableModel)hostTable.getModel()).setNumRows(0);
((DefaultTableModel)hostTable.getModel()).setDataVector(hostData,
hostTableColumns);
hostTable.setEditable(false);
- Object[][] connectionData = getConnectionsTableData();
- ((DefaultTableModel)connectionsTable.getModel()).setNumRows(0);
- ((DefaultTableModel)connectionsTable.getModel()).setDataVector(
- connectionData, connectionsTableColumns);
- connectionsTable.setEditable(false);
updateRunning();
if (!columnsSized) {
updateTableColumnWidths();
@@ -608,7 +563,6 @@
}
public void updateTableColumnWidths() {
- connectionsTable.sizeColumnsToFitData();
hostTable.sizeColumnsToFitData();
}
Modified:
trunk/embedded/src/main/java/com/metamatrix/jdbc/transport/LocalServerConnection.java
===================================================================
---
trunk/embedded/src/main/java/com/metamatrix/jdbc/transport/LocalServerConnection.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/embedded/src/main/java/com/metamatrix/jdbc/transport/LocalServerConnection.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -39,6 +39,7 @@
import com.metamatrix.jdbc.JDBCPlugin;
import com.metamatrix.platform.security.api.LogonResult;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
+import com.metamatrix.platform.security.api.SessionToken;
public class LocalServerConnection implements ServerConnection {
@@ -49,11 +50,11 @@
private ServerConnectionListener listener;
public LocalServerConnection(MetaMatrixSessionID sessionId, Properties
connectionProperties, ClientSideDQP dqp, ServerConnectionListener listener) {
- result = new LogonResult(sessionId,
connectionProperties.getProperty(MMURL.CONNECTION.USER_NAME), connectionProperties,
"local"); //$NON-NLS-1$
+ result = new LogonResult(new SessionToken(sessionId,
connectionProperties.getProperty(MMURL.CONNECTION.USER_NAME)), connectionProperties,
"local"); //$NON-NLS-1$
//Initialize the workContext
workContext = new DQPWorkContext();
- workContext.setSessionId(result.getSessionID());
+ workContext.setSessionToken(result.getSessionToken());
workContext.setVdbName(connectionProperties.getProperty(MMURL.JDBC.VDB_NAME));
workContext.setVdbVersion(connectionProperties.getProperty(MMURL.JDBC.VDB_VERSION));
DQPWorkContext.setWorkContext(workContext);
@@ -66,6 +67,7 @@
}
}
+ @SuppressWarnings("unchecked")
public <T> T getService(Class<T> iface) {
if (iface != ClientSideDQP.class) {
throw new IllegalArgumentException("unknown service"); //$NON-NLS-1$
Modified:
trunk/embedded/src/main/java/com/metamatrix/jdbc/transport/LocalTransportHandler.java
===================================================================
---
trunk/embedded/src/main/java/com/metamatrix/jdbc/transport/LocalTransportHandler.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/embedded/src/main/java/com/metamatrix/jdbc/transport/LocalTransportHandler.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -24,9 +24,8 @@
import java.util.ArrayList;
import java.util.Properties;
-import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.atomic.AtomicInteger;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
import com.metamatrix.common.comm.api.ServerConnection;
import com.metamatrix.common.comm.api.ServerConnectionFactory;
import com.metamatrix.common.comm.api.ServerConnectionListener;
@@ -36,14 +35,14 @@
public class LocalTransportHandler implements ServerConnectionFactory {
- private AtomicLong SESSION_ID = new AtomicLong(1);
+ private AtomicInteger SESSION_ID = new AtomicInteger();
private ConnectionListenerList listenerList = new ConnectionListenerList();
private ClientSideDQP dqp;
/**
* Default constructor - used by reflection to create a new instance.
*/
- public LocalTransportHandler(ClientSideDQP dqp) throws
ApplicationInitializationException {
+ public LocalTransportHandler(ClientSideDQP dqp) {
this.dqp = dqp;
}
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 2009-04-06
14:29:25 UTC (rev 718)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -193,6 +193,7 @@
if(holder != null && !holder.isCanceled()) {
RequestInfo req = new RequestInfo(holder.requestID,
holder.requestMsg.getCommandString(), holder.requestMsg.getSubmittedTimestamp(),
holder.requestMsg.getProcessingTimestamp());
+ req.setSessionToken(holder.dqpWorkContext.getSessionToken());
if (holder.getTransactionContext() != null &&
holder.getTransactionContext().isInTransaction()) {
req.setTransactionId(holder.getTransactionContext().getTxnID());
}
@@ -207,7 +208,8 @@
// add all the subrequest messages
AtomicRequestMessage arm = conInfo.getAtomicRequestMessage();
RequestInfo info = new RequestInfo(arm.getRequestID(),
arm.getCommand().toString(), arm.getSubmittedTimestamp(), arm.getProcessingTimestamp());
- info.setConnectorBindingUUID(arm.getConnectorBindingID());
+ info.setSessionToken(holder.dqpWorkContext.getSessionToken());
+ info.setConnectorBindingUUID(arm.getConnectorBindingID());
info.setNodeID(arm.getAtomicRequestID().getNodeID());
results.add(info);
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -46,8 +46,6 @@
CONTEXTS.set(context);
}
- private MetaMatrixSessionID sessionId;
- private String userName;
private Serializable trustedPayload;
private String vdbName;
private String vdbVersion;
@@ -70,7 +68,10 @@
* @return
*/
public String getUserName() {
- return userName;
+ if (this.sessionToken == null) {
+ return null;
+ }
+ return this.sessionToken.getUsername();
}
/**
@@ -97,13 +98,6 @@
/**
* @param string
*/
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- /**
- * @param string
- */
public void setVdbName(String vdbName) {
this.vdbName = vdbName;
}
@@ -116,17 +110,19 @@
}
public String getConnectionID() {
- return this.sessionId!=null?this.sessionId.toString():null;
+ if (this.sessionToken == null) {
+ return null;
+ }
+ return this.sessionToken.getSessionIDValue();
}
public MetaMatrixSessionID getSessionId() {
- return this.sessionId;
+ if (this.sessionToken == null) {
+ return null;
+ }
+ return this.sessionToken.getSessionID();
}
- public void setSessionId(MetaMatrixSessionID sessionId) {
- this.sessionId = sessionId;
- }
-
public void setAppName(String appName) {
this.appName = appName;
}
Modified:
trunk/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java
===================================================================
---
trunk/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -32,6 +32,7 @@
import com.metamatrix.core.util.UnitTestUtil;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
+import com.metamatrix.platform.security.api.SessionToken;
public class TestAtomicRequestMessage extends TestCase {
@@ -46,7 +47,7 @@
public static AtomicRequestMessage example() {
RequestMessage rm = new RequestMessage();
DQPWorkContext workContext = new DQPWorkContext();
- workContext.setSessionId(new MetaMatrixSessionID(2));
+ workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(2),
"foo")); //$NON-NLS-1$
AtomicRequestMessage message = new AtomicRequestMessage(rm, workContext, 1000);
message.setCommand(TestQueryImpl.helpExample());
message.setFetchSize(100);
@@ -68,7 +69,7 @@
assertEquals(new Date(12345678L), copy.getProcessingTimestamp());
assertEquals(new RequestID(5000L), copy.getRequestID());
- assertEquals("00000000-0000-0002-0000-000000000002",
copy.getWorkContext().getConnectionID()); //$NON-NLS-1$
+ assertEquals("2", copy.getWorkContext().getConnectionID());
//$NON-NLS-1$
//AtomicRequestMessage-specific stuff
assertEquals("connectorBindingID", copy.getConnectorBindingID());
//$NON-NLS-1$
assertEquals(new ConnectorID("10000"), copy.getConnectorID());
//$NON-NLS-1$
Modified:
trunk/engine/src/test/java/com/metamatrix/dqp/service/TestCustomizableTrackingService.java
===================================================================
---
trunk/engine/src/test/java/com/metamatrix/dqp/service/TestCustomizableTrackingService.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/engine/src/test/java/com/metamatrix/dqp/service/TestCustomizableTrackingService.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -50,6 +50,7 @@
import com.metamatrix.dqp.spi.CommandLoggerSPI;
import com.metamatrix.dqp.spi.TrackerLogConstants;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
+import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.TestQuery;
import com.metamatrix.query.unittest.FakeMetadataFactory;
@@ -248,8 +249,7 @@
DQPWorkContext workContext = new DQPWorkContext();
workContext.setVdbName(vdbName);
workContext.setVdbVersion(vdbVersion);
- workContext.setSessionId(sessionID);
- workContext.setUserName(principal);
+ workContext.setSessionToken(new SessionToken(sessionID, principal));
DQPWorkContext.setWorkContext(workContext);
RequestMessage reqMsg = new RequestMessage(command);
Modified:
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -37,12 +37,6 @@
import org.teiid.connector.internal.ConnectorPropertyNames;
import org.teiid.connector.language.IProcedure;
import org.teiid.connector.xa.api.TransactionContext;
-import org.teiid.dqp.internal.datamgr.impl.AsynchConnectorWorkItem;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorWorkItem;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorWrapper;
-import org.teiid.dqp.internal.datamgr.impl.ProcedureBatchHandler;
-import org.teiid.dqp.internal.datamgr.impl.SynchConnectorWorkItem;
import org.teiid.dqp.internal.datamgr.language.LanguageBridgeFactory;
import org.teiid.dqp.internal.process.DQPWorkContext;
@@ -56,6 +50,8 @@
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.service.FakeMetadataService;
import com.metamatrix.dqp.util.LogConstants;
+import com.metamatrix.platform.security.api.MetaMatrixSessionID;
+import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.parser.QueryParser;
import com.metamatrix.query.resolver.QueryResolver;
@@ -87,7 +83,7 @@
int nodeid) throws Exception {
RequestMessage rm = new RequestMessage();
DQPWorkContext workContext = new DQPWorkContext();
- workContext.setUserName("foo"); //$NON-NLS-1$
+ workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(1),
"foo")); //$NON-NLS-1$
AtomicRequestMessage request = new AtomicRequestMessage(rm,
workContext, nodeid);
request.setCommand(helpGetCommand(
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2009-04-06
14:29:25 UTC (rev 718)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -49,6 +49,7 @@
import com.metamatrix.dqp.service.FakeVDBService;
import com.metamatrix.jdbc.api.ExecutionProperties;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
+import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
import com.metamatrix.query.unittest.FakeMetadataFactory;
@@ -67,7 +68,7 @@
DQPWorkContext workContext = new DQPWorkContext();
workContext.setVdbName("bqt"); //$NON-NLS-1$
workContext.setVdbVersion("1"); //$NON-NLS-1$
- workContext.setSessionId(new MetaMatrixSessionID(1));
+ workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(1),
"foo")); //$NON-NLS-1$
DQPWorkContext.setWorkContext(workContext);
String vdbName = "bqt"; //$NON-NLS-1$
@@ -169,14 +170,14 @@
String sql = "SELECT env('sessionid') as SessionID";
//$NON-NLS-1$
String userName = "1"; //$NON-NLS-1$
ResultsMessage rm = helpExecute(sql, userName);
- assertEquals("00000000-0000-0001-0000-000000000001",
rm.getResults()[0].get(0));
+ assertEquals("1", rm.getResults()[0].get(0)); //$NON-NLS-1$
}
public void testEnvSessionIdMixedCase() throws Exception {
String sql = "SELECT env('sEsSIonId') as SessionID";
//$NON-NLS-1$
String userName = "1"; //$NON-NLS-1$
ResultsMessage rm = helpExecute(sql, userName);
- assertEquals("00000000-0000-0001-0000-000000000001",
rm.getResults()[0].get(0));
+ assertEquals("1", rm.getResults()[0].get(0)); //$NON-NLS-1$
}
public void testTxnAutoWrap() throws Exception {
@@ -256,8 +257,7 @@
private ResultsMessage helpExecute(String sql, String userName, int sessionid,
boolean txnAutoWrap) throws Exception {
RequestMessage reqMsg = exampleRequestMessage(sql);
- DQPWorkContext.getWorkContext().setUserName(userName);
- DQPWorkContext.getWorkContext().setSessionId(new
MetaMatrixSessionID(sessionid));
+ DQPWorkContext.getWorkContext().setSessionToken(new SessionToken(new
MetaMatrixSessionID(sessionid), userName));
if (txnAutoWrap) {
reqMsg.setTxnAutoWrapMode(ExecutionProperties.AUTO_WRAP_ON);
}
Modified:
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -41,6 +41,7 @@
import com.metamatrix.dqp.message.RequestID;
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
+import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.processor.QueryProcessor;
import com.metamatrix.query.sql.lang.Command;
@@ -147,7 +148,7 @@
if (workContext == null) {
workContext = new DQPWorkContext();
- workContext.setSessionId(new MetaMatrixSessionID(id.getConnectionID()));
+ workContext.setSessionToken(new SessionToken(new
MetaMatrixSessionID(Long.valueOf(id.getConnectionID())), "foo")); //$NON-NLS-1$
}
RequestWorkItem workItem = new RequestWorkItem(rm, requestMsg, null, null, id,
workContext);
workItem.setOriginalCommand(originalCommand);
Modified:
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -28,6 +28,7 @@
import com.metamatrix.core.util.UnitTestUtil;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
+import com.metamatrix.platform.security.api.SessionToken;
public class TestDQPWorkContext extends TestCase {
@@ -43,18 +44,17 @@
public static DQPWorkContext example() {
DQPWorkContext message = new DQPWorkContext();
message.setTrustedPayload("myTrustedPayload"); //$NON-NLS-1$
- message.setUserName("userName"); //$NON-NLS-1$
message.setVdbName("vdbName"); //$NON-NLS-1$
message.setVdbVersion("vdbVersion"); //$NON-NLS-1$
- message.setAppName("querybuilder");
- message.setSessionId(new MetaMatrixSessionID(5));
+ message.setAppName("querybuilder"); //$NON-NLS-1$
+ message.setSessionToken(new SessionToken(new MetaMatrixSessionID(5),
"userName")); //$NON-NLS-1$
return message;
}
public void testSerialize() throws Exception {
DQPWorkContext copy = UnitTestUtil.helpSerialize(example());
- assertEquals("5", "5"); //$NON-NLS-1$
+ assertEquals("5", copy.getConnectionID()); //$NON-NLS-1$
assertEquals("myTrustedPayload", copy.getTrustedPayload()); //$NON-NLS-1$
assertEquals("userName", copy.getUserName()); //$NON-NLS-1$
assertEquals("vdbName", copy.getVdbName()); //$NON-NLS-1$
Modified:
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -59,6 +59,7 @@
import com.metamatrix.dqp.service.FakeBufferService;
import com.metamatrix.dqp.service.FakeVDBService;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
+import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
@@ -127,7 +128,7 @@
DQPWorkContext workContext = new DQPWorkContext();
workContext.setVdbName("MyVDB"); //$NON-NLS-1$
workContext.setVdbVersion("1"); //$NON-NLS-1$
- workContext.setSessionId(new MetaMatrixSessionID(1));
+ workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(1),
"foo")); //$NON-NLS-1$
RequestID requestID = workContext.getRequestID(original.getExecutionId());
context = new CommandContext();
Modified:
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -45,6 +45,7 @@
import com.metamatrix.dqp.service.FakeVDBService;
import com.metamatrix.dqp.service.MetadataService;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
+import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.parser.QueryParser;
@@ -73,7 +74,7 @@
DQPWorkContext workContext = new DQPWorkContext();
workContext.setVdbName("MyVDB"); //$NON-NLS-1$
workContext.setVdbVersion("1"); //$NON-NLS-1$
- workContext.setSessionId(new MetaMatrixSessionID(1));
+ workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(1),
"foo")); //$NON-NLS-1$
// Initialize components
RequestID requestID = workContext.getRequestID(1);
@@ -156,7 +157,7 @@
DQPWorkContext workContext = new DQPWorkContext();
workContext.setVdbName("MyVDB"); //$NON-NLS-1$
workContext.setVdbVersion("1"); //$NON-NLS-1$
- workContext.setSessionId(new MetaMatrixSessionID(1));
+ workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(1),
"foo")); //$NON-NLS-1$
return mdProc.processMessage(workContext.getRequestID(1), workContext, sql,
true);
}
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 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -42,6 +42,7 @@
import com.metamatrix.common.buffer.BufferManagerFactory;
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
+import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.TestOptimizer;
import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
@@ -58,7 +59,7 @@
public class TestPreparedStatement extends TestCase{
- private static final long SESSION_ID = 6;
+ private static final int SESSION_ID = 6;
private static boolean DEBUG = false;
@@ -171,7 +172,7 @@
}
private ProcessorPlan helpGetProcessorPlan(String preparedSql, List values,
- PreparedPlanCache prepPlanCache, long conn)
+ PreparedPlanCache prepPlanCache, int conn)
throws MetaMatrixComponentException, QueryParserException,
QueryResolverException, QueryValidatorException,
QueryPlannerException {
@@ -181,7 +182,7 @@
}
static ProcessorPlan helpGetProcessorPlan(String preparedSql, List values,
- CapabilitiesFinder capFinder, QueryMetadataInterface metadata, PreparedPlanCache
prepPlanCache, long conn, boolean callableStatement, boolean limitResults)
+ CapabilitiesFinder capFinder, QueryMetadataInterface metadata, PreparedPlanCache
prepPlanCache, int conn, boolean callableStatement, boolean limitResults)
throws MetaMatrixComponentException, QueryParserException,
QueryResolverException, QueryValidatorException,
QueryPlannerException {
@@ -196,10 +197,9 @@
}
DQPWorkContext workContext = new DQPWorkContext();
- workContext.setVdbName("example1");
- workContext.setVdbVersion("1");
- workContext.setSessionId(new MetaMatrixSessionID(conn));
-
+ workContext.setVdbName("example1"); //$NON-NLS-1$
+ workContext.setVdbVersion("1"); //$NON-NLS-1$
+ workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(conn),
"foo")); //$NON-NLS-1$
PreparedStatementRequest serverRequest = new
PreparedStatementRequest(prepPlanCache) {
@Override
protected void createProcessor()
@@ -207,7 +207,7 @@
//don't bother
}
};
- FakeApplicationEnvironment env = new FakeApplicationEnvironment(metadata,
"example1", "1", "pm1", "1",
"BINDING");
+ FakeApplicationEnvironment env = new FakeApplicationEnvironment(metadata,
"example1", "1", "pm1", "1", "BINDING");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
serverRequest.initialize(request, env,
BufferManagerFactory.getStandaloneBufferManager(), null, new HashMap(), null, DEBUG, null,
workContext, 101024);
serverRequest.setMetadata(capFinder, metadata, null);
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 2009-04-06
14:29:25 UTC (rev 718)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -54,6 +54,7 @@
import com.metamatrix.dqp.service.FakeVDBService;
import com.metamatrix.dqp.service.MetadataService;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
+import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.parser.QueryParser;
@@ -96,7 +97,7 @@
DQPWorkContext workContext = new DQPWorkContext();
workContext.setVdbName(VDB);
workContext.setVdbVersion(VDB_VERSION);
- workContext.setSessionId(new MetaMatrixSessionID(5));
+ workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(5),
"foo")); //$NON-NLS-1$
FakeApplicationEnvironment environment =
new FakeApplicationEnvironment(metadata, VDB, VDB_VERSION, MODEL, BINDING_ID,
BINDING_NAME);
Request request = helpProcessMessage(environment, message, null, workContext);
@@ -123,7 +124,7 @@
DQPWorkContext workContext = new DQPWorkContext();
workContext.setVdbName(VDB);
workContext.setVdbVersion(VDB_VERSION);
- workContext.setSessionId(new MetaMatrixSessionID(5));
+ workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(5),
"foo")); //$NON-NLS-1$
FakeApplicationEnvironment environment =
new FakeApplicationEnvironment(metadata, VDB, VDB_VERSION, MODEL, BINDING_ID,
BINDING_NAME);
@@ -153,7 +154,7 @@
DQPWorkContext workContext = new DQPWorkContext();
workContext.setVdbName(VDB);
workContext.setVdbVersion(VDB_VERSION);
- workContext.setSessionId(new MetaMatrixSessionID(5));
+ workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(5),
"foo")); //$NON-NLS-1$
helpProcessMessage(environment, message, null, workContext);
@@ -176,9 +177,9 @@
DQPWorkContext workContext = new DQPWorkContext();
workContext.setVdbName(VDB);
workContext.setVdbVersion(VDB_VERSION);
- workContext.setSessionId(new MetaMatrixSessionID(5));
+ workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(5),
"foo")); //$NON-NLS-1$
Request request = helpProcessMessage(environment, message, null, workContext);
- assertEquals("00000000-0000-0005-0000-000000000005",
request.context.getEnvironmentProperties().get(ContextProperties.SESSION_ID));
+ assertEquals("5",
request.context.getEnvironmentProperties().get(ContextProperties.SESSION_ID));
//$NON-NLS-1$
}
private Request helpProcessMessage(FakeApplicationEnvironment environment,
@@ -223,7 +224,7 @@
DQPWorkContext workContext = new DQPWorkContext();
workContext.setVdbName(VDB);
workContext.setVdbVersion(VDB_VERSION);
- workContext.setSessionId(new MetaMatrixSessionID(5));
+ workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(5),
"foo")); //$NON-NLS-1$
message.setPreparedStatement(true);
message.setParameterValues(new ArrayList());
Modified:
trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -48,6 +48,7 @@
import com.metamatrix.admin.api.objects.Model;
import com.metamatrix.admin.api.objects.Request;
import com.metamatrix.admin.api.objects.Resource;
+import com.metamatrix.admin.api.objects.Session;
import com.metamatrix.admin.api.objects.SystemObject;
import com.metamatrix.admin.api.objects.VDB;
import com.metamatrix.admin.api.server.ServerMonitoringAdmin;
@@ -786,8 +787,6 @@
results = new ArrayList(requests.size());
for (Iterator iter = requests.iterator(); iter.hasNext();) {
RequestInfo info = (RequestInfo)iter.next();
- SessionToken st = info.getSessionToken();
-
String[] identifierParts = new String[2];
identifierParts[0] = info.getRequestID().getConnectionID();
@@ -815,9 +814,7 @@
if (info.getTransactionId() != null) {
request.setTransactionID(info.getTransactionId());
}
- if (st != null && st.getSessionID() != null) {
- request.setUserName(st.getUsername());
- }
+ request.setUserName(info.getUserName());
results.add(request);
}
@@ -888,15 +885,14 @@
* @return a <code>Collection</code> of
<code>com.metamatrix.admin.api.Session</code>
* @since 4.3
*/
- public Collection getSessions(String identifier) throws AdminException {
+ public Collection<Session> getSessions(String identifier) throws AdminException
{
if (identifier == null) {
throwProcessingException("AdminImpl.requiredparameter", new
Object[] {}); //$NON-NLS-1$
}
ArrayList results = null;
try {
- Collection sessions = null;
- sessions = getSessionServiceProxy().getActiveSessions();
+ Collection sessions = getSessionServiceProxy().getActiveSessions();
//convert results into MMSession objects
results = new ArrayList(sessions.size());
Modified:
trunk/server/src/main/java/com/metamatrix/admin/server/ServerRuntimeStateAdminImpl.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/admin/server/ServerRuntimeStateAdminImpl.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/server/src/main/java/com/metamatrix/admin/server/ServerRuntimeStateAdminImpl.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -29,6 +29,8 @@
import java.util.List;
import java.util.Map;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
import com.metamatrix.admin.api.exception.AdminComponentException;
import com.metamatrix.admin.api.exception.AdminException;
import com.metamatrix.admin.api.exception.AdminProcessingException;
@@ -480,9 +482,16 @@
throwProcessingException("AdminImpl.requiredparameter", new
Object[] {}); //$NON-NLS-1$
}
+ long sessionIDStringLong = -1;
try {
- MetaMatrixSessionID sessionID = new MetaMatrixSessionID(identifier);
- getSessionServiceProxy().terminateSession(sessionID, null);
+ sessionIDStringLong = Long.parseLong(identifier);
+ } catch (Exception e) {
+
throwProcessingException("ServerRuntimeStateAdminImpl.Invalid_Session_Identifier",
new Object[] {identifier}); //$NON-NLS-1$
+ }
+
+ try {
+ MetaMatrixSessionID sessionID = new MetaMatrixSessionID(sessionIDStringLong);
+ getSessionServiceProxy().terminateSession(sessionID,
DQPWorkContext.getWorkContext().getSessionId());
} catch(IllegalArgumentException e) {
throw new AdminProcessingException(e);
} catch (InvalidSessionException e) {
Modified:
trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/LogonImpl.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/LogonImpl.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/LogonImpl.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -46,6 +46,7 @@
import com.metamatrix.platform.security.api.LogonResult;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
+import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.platform.security.api.service.SessionServiceInterface;
import com.metamatrix.platform.security.util.LogSecurityConstants;
import com.metamatrix.platform.service.api.exception.ServiceException;
@@ -91,7 +92,7 @@
MetaMatrixSessionID sessionID = updateDQPContext(sessionInfo);
LogManager.logDetail(LogSecurityConstants.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(sessionID, sessionInfo.getUserName(),
sessionInfo.getProductInfo(), clusterName);
+ return new LogonResult(sessionInfo.getSessionToken(), sessionInfo.getProductInfo(),
clusterName);
} catch (MetaMatrixAuthenticationException e) {
throw new LogonException(e, e.getMessage());
} catch (ServiceException e) {
@@ -145,9 +146,7 @@
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
workContext.setSessionToken(sessionInfo.getSessionToken());
workContext.setAppName(sessionInfo.getApplicationName());
- workContext.setSessionId(sessionInfo.getSessionID());
workContext.setTrustedPayload(sessionInfo.getTrustedToken());
- workContext.setUserName(sessionInfo.getUserName());
workContext.setVdbName(sessionInfo.getProductInfo(ProductInfoConstants.VIRTUAL_DB));
workContext.setVdbVersion(sessionInfo.getProductInfo(ProductInfoConstants.VDB_VERSION));
return sessionID;
@@ -175,16 +174,19 @@
}
@Override
- public void assertIdentity(MetaMatrixSessionID sessionId)
+ public void assertIdentity(SessionToken sessionId)
throws InvalidSessionException, MetaMatrixComponentException {
MetaMatrixSessionInfo sessionInfo;
try {
- sessionInfo = this.service.validateSession(sessionId);
+ sessionInfo = this.service.validateSession(sessionId.getSessionID());
} catch (SessionServiceException e) {
throw new MetaMatrixComponentException(e);
} catch (ServiceException e) {
throw new MetaMatrixComponentException(e);
}
+ if (!sessionInfo.getSessionToken().equals(sessionInfo.getSessionToken())) {
+ throw new InvalidSessionException();
+ }
this.updateDQPContext(sessionInfo);
}
Modified: trunk/server/src/main/java/com/metamatrix/common/id/dbid/DBIDController.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/common/id/dbid/DBIDController.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/server/src/main/java/com/metamatrix/common/id/dbid/DBIDController.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -24,23 +24,8 @@
public interface DBIDController {
- // call to set the block size increments for a given context.
- void setContextBlockSize(String context, long size);
-
// call to get a unique id for the given context and by default
// the id numbers cannot be rolled over and reused.
- long getUniqueID(String context) throws DBIDGeneratorException;
+ long getID(String context) throws DBIDGeneratorException;
- // call to get a unique id for the given context and pass true if
- // the id numbers can be rolled over and reused.
- long getUniqueID(String context, boolean enableRollOver) throws
DBIDGeneratorException;
-
-
- /**
- * Call when the DBIDGenerator is no longer needed and the database connections
- * can be closed.
- */
- void shutDown();
-
-
}
Modified: trunk/server/src/main/java/com/metamatrix/common/id/dbid/DBIDGenerator.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/id/dbid/DBIDGenerator.java 2009-04-06
14:29:25 UTC (rev 718)
+++ trunk/server/src/main/java/com/metamatrix/common/id/dbid/DBIDGenerator.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -22,38 +22,19 @@
package com.metamatrix.common.id.dbid;
-import com.metamatrix.common.CommonPlugin;
import com.metamatrix.common.connection.ManagedConnectionException;
import com.metamatrix.common.id.dbid.spi.InMemoryIDController;
import com.metamatrix.common.id.dbid.spi.jdbc.PersistentIDController;
-import com.metamatrix.common.util.ErrorMessageKeys;
import com.metamatrix.core.MetaMatrixRuntimeException;
-public class DBIDGenerator {
+public class DBIDGenerator implements DBIDController {
- public final static String VM_ID = "VM"; //$NON-NLS-1$
- public final static String SERVICE_ID = "Service"; //$NON-NLS-1$
-
private static DBIDGenerator generator = new DBIDGenerator();
private DBIDController controller;
private DBIDGenerator() {
setUseMemoryIDGeneration(false);
}
- /**
- * call to get a unique id for the given context and pass true if
- * the id numbers can be rolled over and reused.
- * @param context that identifies a unique entity
- * @param enableRollOver is true if the ids can reused
- * @return long is the next id
- */
- public long getID(String context, boolean enableRollOver) throws
DBIDGeneratorException {
- try {
- return getUniqueID(context, enableRollOver);
- } catch (Exception e) {
- throw new DBIDGeneratorException(e, "Error creating id for " +
context + " context."); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
/**
* Call to get a unique id for the given context and by default the
@@ -63,41 +44,13 @@
*/
public long getID(String context) throws DBIDGeneratorException {
try {
- return getUniqueID(context, true);
+ return controller.getID(context);
} catch (Exception e) {
- throw new DBIDGeneratorException(e, ErrorMessageKeys.ID_ERR_0011,
CommonPlugin.Util.getString(ErrorMessageKeys.ID_ERR_0011, context));
+ throw new DBIDGeneratorException(e, "Error creating id for " +
context + " context."); //$NON-NLS-1$ //$NON-NLS-2$
}
}
/**
- * Call to set the incremental block size for a specific context. This
- * is a way to tune the caching which will reduce the number of database
- * reads that occur. By increasing the cache, it should reduce the
- * number of database reads.
- * @param context that identifies a unique entity
- * @param cache is the size of the blocks to use
-
- */
- public void setCacheBlockSize(String context, long cache) throws
DBIDGeneratorException {
- try {
- setContextBlockSize(context, cache);
- } catch (Exception e) {
- throw new DBIDGeneratorException(e, ErrorMessageKeys.ID_ERR_0012,
CommonPlugin.Util.getString(ErrorMessageKeys.ID_ERR_0012, context));
- }
- }
-
- /**
- * Call when the persistent storage of ID's is not to be used. This will cause
- * the id's to be generated in memory and will not be written to the database
- * for later use for a starting point.
- * This was made available for the CDK because it needs to load runtime metadata
- * disconnected from the application server or database.
- */
- public void setUseMemoryIDGeneration() {
- controller = new InMemoryIDController();
- }
-
- /**
* Call to switch whether persistent storage of ID's is to be used.
* @param useInMemory whether or not to use in Memory ID generation
*/
@@ -113,28 +66,8 @@
}
}
- /**
- * Call when the DBIDGenerator is no longer needed and the database connections
- * can be closed.
- */
- public void shutDown() {
- if (controller != null) {
- controller.shutDown();
- }
- }
-
public static DBIDGenerator getInstance() {
return generator;
}
- private synchronized long getUniqueID(String context, boolean enableRollOver) throws
DBIDGeneratorException {
- return controller.getUniqueID(context, enableRollOver);
- }
- private void setContextBlockSize(String context, long size) {
- controller.setContextBlockSize(context, size);
- }
-
-}
-
-
-
+}
\ No newline at end of file
Modified: trunk/server/src/main/java/com/metamatrix/common/id/dbid/ReservedIDBlock.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/common/id/dbid/ReservedIDBlock.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/server/src/main/java/com/metamatrix/common/id/dbid/ReservedIDBlock.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -24,9 +24,6 @@
import java.io.Serializable;
-import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.common.util.ErrorMessageKeys;
-
/**
* Used by DBIDGenerator to reserve a block of uniqueIDs used
* to create ID objects.
@@ -38,41 +35,23 @@
*/
public final static long NO_ID_AVAILABLE = -1;
- private String context;
+ private long sequence;
- private long first;
- private long last;
- private long next;
-
// indicates the maximum number this context can have
private long max;
- // controlls if when the max number is reached, whether the
- // numbers will wrap around and start over.
- private boolean wrappable = false;
-
/**
* Construct a new instance with the first ID and last ID in the block.
* @param first Defines the first id in this block.
* @param last Defines the last id in the block.
* @throws IllegalArgumentException if first > last
*/
- public ReservedIDBlock(String context, long first, long last, long max) {
-
- if (first > last) {
- throw new
IllegalArgumentException(CommonPlugin.Util.getString(ErrorMessageKeys.ID_ERR_0013,
- new Object[] {String.valueOf(first), String.valueOf(last)}));
- }
-
- this.context = context;
-
- this.first = first;
- this.next = first;
- if (last > max) {
- last = max;
- }
-
- this.last = last;
+ public ReservedIDBlock() {
+
+ }
+
+ public void setBlockValues(long first, long max) {
+ this.sequence = first;
this.max = max;
}
@@ -82,88 +61,15 @@
* @return long nextID in block
*/
public long getNextID() {
- if (next > last) {
+ if (max == 0) {
+ return NO_ID_AVAILABLE;
+ }
+ long result = sequence++;
+ if (result > max) {
return NO_ID_AVAILABLE;
}
- next++;
- return next-1;
+ return result;
}
- /**
- * Return the last ID that will be used in the block;
- * @return long lastID in block
- */
- public long getLast() {
- return last;
- }
-
- /**
- * Return the context for this ID block;
- * @return String context
- */
-
- public String getContext() {
- return context;
- }
-
- /**
- * Returns boolean indicating if block is all used up.
- * @return true if block is depleted.
- */
- public boolean isDepleted() {
- return (next > last);
- }
-
- public boolean isAtMaximum() {
- if (isDepleted()) {
- return (last >= max ? true : false);
- }
- return false;
- }
-
- /**
- * Call to enable this context to reuse its numbers
- * when the maximum number is reached.
- */
- public void setIsWrappable(boolean enableWrapping) {
- wrappable = enableWrapping;
- }
-
- /**
- * Returns boolean indicating if the numbers can be reused
- * when the maximum number is reached.
- * @return true if block is wrappable
- */
- public boolean isWrappable() {
- return wrappable;
- }
-
- /**
- * Sets the maximum number allowed for this context
- * @param long nexMax is the new maximum number allowed
- */
-// public void setMax(long newMax) {
-// this.max = newMax;
- // }
-
- /**
- * Return the maximum number allowed for this context
- * @return long maximum number
- */
- public long getMax() {
- return max;
- }
-
- /**
- * Return String representation of this instance
- * @return String representation
- */
- public String toString() {
- return "ReservedIDBlock: first = " + first + //$NON-NLS-1$
- " last = " + last + //$NON-NLS-1$
- " next = " + next + //$NON-NLS-1$
- " max = " + max + //$NON-NLS-1$
- " wrappable = " + wrappable; //$NON-NLS-1$
- }
}
Modified:
trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/DBIDSourceTransaction.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/DBIDSourceTransaction.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/DBIDSourceTransaction.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -31,19 +31,7 @@
*/
public interface DBIDSourceTransaction extends TransactionInterface {
-
- /**
- * <p>Create and return a new ReservedIDBlock.</p>
- * <p>Read in nextID from database, createIDBlock, then update nextID in
database.
- *
- * @param blockSize size of id block
- * @param context
- * @param wrapNumber is true when the context is at its maximum limit and
- * the next block should start over at the beginning
- * @return ReservedIDBlock
- * @throws Exception when an error updating or reading the database occurs
- */
- ReservedIDBlock createIDBlock(long blockSize, String context, boolean wrapNumber)
throws Exception;
-
+ void createIDBlock(long blockSize, String context, ReservedIDBlock block) throws
Exception;
+
}
Modified:
trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/InMemoryIDController.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/InMemoryIDController.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/InMemoryIDController.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -22,80 +22,20 @@
package com.metamatrix.common.id.dbid.spi;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
import com.metamatrix.common.id.dbid.DBIDController;
import com.metamatrix.common.id.dbid.DBIDGeneratorException;
-import com.metamatrix.common.id.dbid.ReservedIDBlock;
-
public class InMemoryIDController implements DBIDController {
+
+ private static AtomicLong IDSEQUENCE = new AtomicLong();
- private Map lastIDs = new HashMap();
- private static final long DEFAULT_ID_BLOCK_SIZE = 1000;
+ public InMemoryIDController() {
+ }
- private static Map idBlockMap = new HashMap();
- private static Map blockSizeMap = new HashMap();
-
+ public long getID(String context) throws DBIDGeneratorException {
+ return IDSEQUENCE.getAndIncrement();
+ }
- public InMemoryIDController() {
- }
-
- public ReservedIDBlock createIDBlock(long blockSize, String context) throws
DBIDGeneratorException {
- Object obj = lastIDs.get(context);
- ReservedIDBlock block;
- if (obj == null) {
- block = new ReservedIDBlock(context, 1, blockSize, Long.MAX_VALUE);
- } else {
- ReservedIDBlock lastblock = (ReservedIDBlock) obj;
- long start = lastblock.getLast() + 1;
- block = new ReservedIDBlock(context, start, start + blockSize,
Long.MAX_VALUE);
- }
-
- lastIDs.put(context, block);
-
- return block;
-
- }
-
- // the option to enableRollOver does not apply to memory ids
- public long getUniqueID(String context, boolean enableRollOver) throws
DBIDGeneratorException {
- return getUniqueID(context);
-
- }
-
- public long getUniqueID(String context) throws DBIDGeneratorException {
- ReservedIDBlock idBlock = (ReservedIDBlock) idBlockMap.get(context);
-
- if (idBlock == null || idBlock.isDepleted()) {
- // get block size for context
- // if no block size exists then use default.
- Long bs = (Long) blockSizeMap.get(context);
- long bSize = DEFAULT_ID_BLOCK_SIZE;
- if (bs != null) {
- bSize = bs.longValue();
- }
- idBlock = createIDBlock(bSize, context);
- idBlockMap.put(context, idBlock);
- }
- return idBlock.getNextID();
-
-
-
- }
-
-
- public void setContextBlockSize(String context, long size) {
- blockSizeMap.put(context, new Long(size));
- }
-
- /**
- * Nothing to shutdown when inmemory is used.
- */
- public void shutDown() {
-
- }
-
-
-}
+}
Modified:
trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/jdbc/DBIDResourceTransaction.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/jdbc/DBIDResourceTransaction.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/jdbc/DBIDResourceTransaction.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -35,7 +35,6 @@
import com.metamatrix.common.id.dbid.DBIDGeneratorException;
import com.metamatrix.common.id.dbid.ReservedIDBlock;
import com.metamatrix.common.id.dbid.spi.DBIDSourceTransaction;
-import com.metamatrix.common.jdbc.JDBCPlatform;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.ErrorMessageKeys;
import com.metamatrix.common.util.LogCommonConstants;
@@ -46,13 +45,6 @@
public class DBIDResourceTransaction extends BaseTransaction implements
DBIDSourceTransaction {
private Connection jdbcConnection;
-// private static long columnMax=-1;
- private static long columnMax=999999999;
-
- private static final String NINE = "9"; //$NON-NLS-1$
- private static final int INSERT_RETRIES = 5;
-
-
/**
* Create a new instance of a transaction for a managed connection.
* @param connectionPool the pool to which the transaction should return the
connection when completed
@@ -77,21 +69,11 @@
}
-
- /**
- * <p>Create and return a new ReservedIDBlock.</p>
- * <p>Read in nextID from database, createIDBlock, then update nextID in
database.
- *
- * @param blockSize size of id block
- * @return ReservedIDBlock instance
- * @throws TransactionServiceException when an error updating or reading the database
occurs
- */
- public ReservedIDBlock createIDBlock(long blockSize, String context, boolean
wrapNumber) throws Exception {
-
- long idValue = -1;
+
+ @Override
+ public void createIDBlock(long blockSize, String context,
+ ReservedIDBlock block) throws Exception {
long startValue = -1;
- long endValue= -1;
- long lastValue = -1;
String sqlSelect = JDBCNames.SELECT_ID_BLOCK;
String sqlUpdate = JDBCNames.UPDATE_ID_BLOCK;
String sqlInsert = JDBCNames.INSERT_ID_BLOCK;
@@ -99,118 +81,49 @@
PreparedStatement insertStatement = null;
PreparedStatement updateStatement = null;
- int retries = 0;
-
try {
+ selectStatement = jdbcConnection.prepareStatement(sqlSelect);
+ selectStatement.setString(1,context);
+ ResultSet results = selectStatement.executeQuery();
- if (columnMax == -1) {
- determineColumnMax();
- }
+ if (results.next()) {
+ startValue = results.getLong(1);
+ } else {
+ LogManager.logInfo(LogCommonConstants.CTX_DBIDGEN,
CommonPlugin.Util.getString("MSG.003.013.0002", //$NON-NLS-1$
+ new Object[] {context, String.valueOf(JDBCNames.START_ID)}) );
+ startValue = JDBCNames.START_ID;
- boolean updateFailed = true;
- while (updateFailed) {
-
- // if not first time thru, then close statements.
- try {
- if (selectStatement != null) selectStatement.close();
- } catch (Exception e) {}
-
- try {
- if (insertStatement != null) insertStatement.close();
- } catch (Exception e) {}
-
- try {
- if (updateStatement != null) updateStatement.close();
- } catch (Exception e) {}
-
- selectStatement = jdbcConnection.prepareStatement(sqlSelect);
- selectStatement.setString(1,context);
- ResultSet results = selectStatement.executeQuery();
-
- if (results.next()) {
- startValue = results.getLong(1);
- } else {
-
- LogManager.logInfo(LogCommonConstants.CTX_DBIDGEN,
CommonPlugin.Util.getString("MSG.003.013.0002", //$NON-NLS-1$
- new Object[] {context, String.valueOf(JDBCNames.START_ID)}) );
-
- startValue = JDBCNames.START_ID;
-
- try {
- insertStatement = jdbcConnection.prepareStatement(sqlInsert);
- insertStatement.setString(1, context);
- insertStatement.setLong(2, startValue);
- int nr = insertStatement.executeUpdate();
- if (nr != 1) {
- String msg =
CommonPlugin.Util.getString("ERR.003.013.0017", //$NON-NLS-1$
- new Object[]
{context, JDBCNames.IDTable.TABLE_NAME});
- LogManager.logCritical(LogCommonConstants.CTX_DBIDGEN, msg);
-// System.out.println(msg);
- throw new DBIDGeneratorException(msg);
- }
- } catch (SQLException sqle) {
- ++retries;
-
- // allow for retries incase multiple servers are adding the same
context
- // a duplicate exception would be thrown
- if (retries >= INSERT_RETRIES) {
- String msg =
CommonPlugin.Util.getString("ERR.003.013.0018", //$NON-NLS-1$
- new Object[] {context, JDBCNames.IDTable.TABLE_NAME});
-
- LogManager.logCritical(LogCommonConstants.CTX_DBIDGEN, msg);
-// System.out.println(msg);
- throw new DBIDGeneratorException(sqle, msg);
-
-// throw sqle;
- }
-
- continue; // try read again
- }
+ insertStatement = jdbcConnection.prepareStatement(sqlInsert);
+ insertStatement.setString(1, context);
+ insertStatement.setLong(2, startValue);
+ int nr = insertStatement.executeUpdate();
+ if (nr != 1) {
+ String msg =
CommonPlugin.Util.getString("ERR.003.013.0017", //$NON-NLS-1$
+ new Object[] {context,
JDBCNames.IDTable.TABLE_NAME});
+ LogManager.logCritical(LogCommonConstants.CTX_DBIDGEN, msg);
+ throw new DBIDGeneratorException(msg);
}
- lastValue = startValue;
+ }
- if (wrapNumber) {
- startValue = JDBCNames.START_ID;
- idValue = JDBCNames.START_ID + blockSize;
-// Integer.parseInt( new Long(blockSize).toString());
- endValue = idValue - 1;
- } else if ( (startValue + blockSize) > columnMax) {
- // if next ending value is greater than allowed, then
- // reset to max allowed
- idValue = columnMax;
- //Integer.parseInt( new Long(columnMax).toString());
- // dont decrement the endValue when at maximum because it
- // leaves 1 extra id available
- endValue = idValue;
- } else {
- idValue = startValue + blockSize;
- //Integer.parseInt( new Long(blockSize).toString());
- endValue = idValue - 1;
- }
+ if ( (startValue + blockSize) > getMaxValue()) {
+ startValue = JDBCNames.START_ID;
+ }
+ long next = startValue + blockSize;
- updateStatement = jdbcConnection.prepareStatement(sqlUpdate);
- updateStatement.setLong(1, idValue);
- updateStatement.setString(2, context);
- updateStatement.setLong(3, lastValue);
- int nrows = updateStatement.executeUpdate();
+ updateStatement = jdbcConnection.prepareStatement(sqlUpdate);
+ updateStatement.setLong(1, next);
+ updateStatement.setString(2, context);
+ int nrows = updateStatement.executeUpdate();
- // if nrows == 1 then update succeeded.
- if (nrows == 1) {
- updateFailed = false;
- break;
- }
-
- // nrows != 0 , something is really wrong, bail
- if (nrows != 0) {
- String msg =
CommonPlugin.Util.getString(ErrorMessageKeys.ID_ERR_0019,
- new Object[] {context,
JDBCNames.IDTable.TABLE_NAME});
- LogManager.logCritical(LogCommonConstants.CTX_DBIDGEN, msg);
- throw new DBIDGeneratorException(msg);
- }
- LogManager.logWarning(LogCommonConstants.CTX_DBIDGEN,
-
CommonPlugin.Util.getString(ErrorMessageKeys.ID_ERR_0020, context));
+ // nrows != 0 , something is really wrong, bail
+ if (nrows != 1) {
+ String msg = CommonPlugin.Util.getString(ErrorMessageKeys.ID_ERR_0019,
+ new Object[] {context,
JDBCNames.IDTable.TABLE_NAME});
+ LogManager.logCritical(LogCommonConstants.CTX_DBIDGEN, msg);
+ throw new DBIDGeneratorException(msg);
}
+ block.setBlockValues(startValue, next - 1);
} catch (DBIDGeneratorException dbe) {
throw dbe;
} catch ( SQLException se ) {
@@ -244,46 +157,9 @@
}
}
}
- ReservedIDBlock idBlock = new ReservedIDBlock(context, startValue, endValue,
columnMax);
-// (idValue == columnMax ? idValue : idValue-1), columnMax);
-// idBlock.setMax(columnMax);
-
- return idBlock;
}
-
- private void determineColumnMax() throws DBIDGeneratorException, SQLException {
-
- if (columnMax > -1) return;
-
- int s = JDBCPlatform.getDatabaseColumnSize(JDBCNames.IDTable.TABLE_NAME,
- JDBCNames.IDTable.ColumnName.NEXT_ID,
- jdbcConnection);
-// Map columns = platform.getDatabaseColumns(JDBCNames.IDTable.TABLE_NAME,
jdbcConnection);
-
- if (s <= 0) {
- LogManager.logCritical(LogCommonConstants.CTX_DBIDGEN,
CommonPlugin.Util.getString(ErrorMessageKeys.ID_ERR_0024,
- new Object[] {JDBCNames.IDTable.TABLE_NAME,
JDBCNames.IDTable.ColumnName.NEXT_ID}));
- throw new DBIDGeneratorException(ErrorMessageKeys.ID_ERR_0024,
CommonPlugin.Util.getString(ErrorMessageKeys.ID_ERR_0021,
- new Object[] {JDBCNames.IDTable.TABLE_NAME,
JDBCNames.IDTable.ColumnName.NEXT_ID}));
-
- }
-
-// DatabaseColumn column = (DatabaseColumn)
columns.get(JDBCNames.IDTable.ColumnName.NEXT_ID);
-
- // build the maximum value
- // e.g. size = 5 then max value = 99999
- if (s > 0) {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < s; i++) {
- sb.append(NINE);
- }
-
- columnMax = Long.parseLong(sb.toString());
- return;
- }
-
- columnMax = -1;
-
+ public long getMaxValue() {
+ return 999999999;
}
}
Modified:
trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/jdbc/JDBCNames.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/jdbc/JDBCNames.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/jdbc/JDBCNames.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -80,9 +80,7 @@
+ SET
+ JDBCNames.IDTable.ColumnName.NEXT_ID + "=
?" //$NON-NLS-1$
+ WHERE
- + JDBCNames.IDTable.ColumnName.ID_CONTEXT + "=
?" //$NON-NLS-1$
- + AND
- + JDBCNames.IDTable.ColumnName.NEXT_ID + "=
?"; //$NON-NLS-1$
+ + JDBCNames.IDTable.ColumnName.ID_CONTEXT + "=
?"; //$NON-NLS-1$
/** Sql statement use to insert an ID in the TransactionID table */
public static final String INSERT_ID_BLOCK
Modified:
trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/jdbc/PersistentIDController.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/jdbc/PersistentIDController.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/jdbc/PersistentIDController.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -30,7 +30,6 @@
import com.metamatrix.common.connection.ManagedConnectionException;
import com.metamatrix.common.connection.TransactionMgr;
import com.metamatrix.common.id.dbid.DBIDController;
-import com.metamatrix.common.id.dbid.DBIDGenerator;
import com.metamatrix.common.id.dbid.DBIDGeneratorException;
import com.metamatrix.common.id.dbid.ReservedIDBlock;
import com.metamatrix.common.util.ErrorMessageKeys;
@@ -39,54 +38,37 @@
private static TransactionMgr transMgr;
-// private static ManagedConnectionPool connectionPool;
+ private static Map<String, ReservedIDBlock> idBlockMap = new HashMap<String,
ReservedIDBlock>();
- private static Map idBlockMap = new HashMap();
- private static Map blockSizeMap = new HashMap();
-
- // Contexts
- public final static String VM_ID = DBIDGenerator.VM_ID;
- public final static String SERVICE_ID = DBIDGenerator.SERVICE_ID;
-
- private final static long VM_ID_BLOCK_SIZE = 1;
- private final static long SERVICE_ID_BLOCK_SIZE = 10;
-
private static final long DEFAULT_ID_BLOCK_SIZE = 100;
-// private static final String DEFAULT_MAXIMUM_CONCURRENT_USERS = "1";
private static final String FACTORY =
"com.metamatrix.common.id.dbid.spi.jdbc.DBIDResourceTransactionFactory";
//$NON-NLS-1$
private static final String PRINCIPAL = "DBID_GENERATOR"; //$NON-NLS-1$
public PersistentIDController() throws ManagedConnectionException {
+ // get the resource connection properties, if system properties where set
+ // prior to this being called they will override.
- // get the resource connection properties, if system properties where set
- // prior to this being called they will override.
+ Properties props = new Properties();
+ //PropertiesUtils.clone(cfgProps, false);
+ props.setProperty(TransactionMgr.FACTORY, FACTORY);
- Properties props = new Properties();
- //PropertiesUtils.clone(cfgProps, false);
- props.setProperty(TransactionMgr.FACTORY, FACTORY);
-
- transMgr = new TransactionMgr(props, PRINCIPAL);
-
-
- // Initialize block size for known contexts.
- blockSizeMap.put(VM_ID, new Long(VM_ID_BLOCK_SIZE));
- blockSizeMap.put(SERVICE_ID, new Long(SERVICE_ID_BLOCK_SIZE));
+ transMgr = new TransactionMgr(props, PRINCIPAL);
}
- private ReservedIDBlock createIDBlock(long blockSize, String context, boolean wrap)
throws DBIDGeneratorException {
-
- ReservedIDBlock block = null;
+ private void setNextBlockValues(long blockSize, String context, ReservedIDBlock
block) throws DBIDGeneratorException {
DBIDResourceTransaction transaction = null;
try {
transaction = (DBIDResourceTransaction) transMgr.getWriteTransaction();
- block = transaction.createIDBlock(blockSize, context, wrap);
+ transaction.createIDBlock(blockSize, context, block);
transaction.commit();
} catch (Exception e) {
try {
- transaction.rollback();
+ if (transaction != null) {
+ transaction.rollback();
+ }
} catch (Exception sqle) {
}
@@ -97,64 +79,27 @@
transaction.close();
}
}
- return block;
}
- public void setContextBlockSize(String context, long size) {
- blockSizeMap.put(context, new Long(size));
- }
+ public long getID(String context)
+ throws DBIDGeneratorException {
+ ReservedIDBlock idBlock = null;
+ synchronized (idBlockMap) {
+ idBlock = idBlockMap.get(context);
+
+ if (idBlock == null) {
+ idBlock = new ReservedIDBlock();
+ idBlockMap.put(context, idBlock);
+ }
+ }
+ synchronized (idBlock) {
+ long result = idBlock.getNextID();
+ if (result != ReservedIDBlock.NO_ID_AVAILABLE) {
+ return result;
+ }
+ setNextBlockValues(DEFAULT_ID_BLOCK_SIZE, context, idBlock);
+ return idBlock.getNextID();
+ }
+ }
-
- public long getUniqueID(String context) throws DBIDGeneratorException {
- return getUniqueID(context, false);
- }
-
- public long getUniqueID(String context, boolean enableRollOver) throws
DBIDGeneratorException {
-
- ReservedIDBlock idBlock = (ReservedIDBlock) idBlockMap.get(context);
-
- if (idBlock == null) {
- long bSize = getBlockSize(context);
- idBlock = createIDBlock(bSize, context, false);
-
- idBlock.setIsWrappable(enableRollOver);
- idBlockMap.put(context, idBlock);
-
- } else if (idBlock.isDepleted()) {
- long bSize = getBlockSize(context);
- if (idBlock.isAtMaximum()) {
- if(idBlock.isWrappable()) {
- idBlock = createIDBlock(bSize, context, true);
- } else {
- throw new DBIDGeneratorException(ErrorMessageKeys.ID_ERR_0015,
CommonPlugin.Util.getString(ErrorMessageKeys.ID_ERR_0015,
- new Object[] {context, String.valueOf(idBlock.getMax())} ));
- }
- } else {
- idBlock = createIDBlock(bSize, context, false);
- }
- idBlock.setIsWrappable(enableRollOver);
- idBlockMap.put(context, idBlock);
- }
-
- return idBlock.getNextID();
- }
-
- private long getBlockSize(String context) {
- // get block size for context
- // if no block size exists then use default.
-
- Long bs = (Long) blockSizeMap.get(context);
- long bSize = DEFAULT_ID_BLOCK_SIZE;
- if (bs != null) {
- bSize = bs.longValue();
- }
-
- return bSize;
- }
-
- public void shutDown() {
- }
-
-
-
}
Modified:
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/ConfigurationAdminAPIImpl.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/ConfigurationAdminAPIImpl.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/ConfigurationAdminAPIImpl.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -483,23 +483,4 @@
return configAdmin.checkPropertiesDecryptable(defns);
}
-
-
- /**
- * @see
com.metamatrix.platform.admin.api.ConfigurationAdminAPI#getProducts(com.metamatrix.platform.security.api.MetaMatrixSessionID)
- * @since 4.2
- */
- public Collection getProducts() throws AuthorizationException,
- InvalidSessionException,
-
MetaMatrixComponentException {
- Collection result = null;
- try {
- result = configAdmin.getProductReleaseInfos();
- } catch (ServiceException e) {
- throw new ComponentNotFoundException(e,
PlatformPlugin.Util.getString("ConfigurationAdminAPIImpl.Problem_getting_Product_Release_Infos",
e.getMessage())); //$NON-NLS-1$
- } catch (ConfigurationException e) {
- throw new MetaMatrixComponentException(e,
PlatformPlugin.Util.getString("ConfigurationAdminAPIImpl.Problem_getting_Product_Release_Infos",
e.getMessage())); //$NON-NLS-1$
- }
- return result;
- }
}
Modified:
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIImpl.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIImpl.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIImpl.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -52,7 +52,6 @@
import com.metamatrix.platform.admin.api.runtime.PscID;
import com.metamatrix.platform.admin.api.runtime.ServiceData;
import com.metamatrix.platform.admin.api.runtime.SystemState;
-import com.metamatrix.platform.config.api.service.ConfigurationServiceInterface;
import com.metamatrix.platform.registry.ClusteredRegistryState;
import com.metamatrix.platform.registry.ProcessRegistryBinding;
import com.metamatrix.platform.registry.ResourceNotBoundException;
@@ -66,7 +65,6 @@
import com.metamatrix.platform.util.ErrorMessageKeys;
import com.metamatrix.platform.util.LogMessageKeys;
import com.metamatrix.platform.util.LogPlatformConstants;
-import com.metamatrix.platform.util.PlatformProxyHelper;
import com.metamatrix.platform.vm.api.controller.ProcessManagement;
import com.metamatrix.platform.vm.controller.ProcessStatistics;
import com.metamatrix.server.HostManagement;
@@ -304,30 +302,6 @@
}
/**
- * Shutdown server and restart.
- *
- * @throws AuthorizationException
- * if caller is not authorized to perform this method.
- * @throws InvalidSessionException
- * if the <code>callerSessionID</code> is not valid or is
expired.
- * @throws MetaMatrixComponentException
- * if an error occurred in communicating with a component.
- */
- public synchronized void bounceServer() throws AuthorizationException,
InvalidSessionException, MetaMatrixComponentException {
-
- // Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- LogManager.logCritical(LogPlatformConstants.CTX_RUNTIME_ADMIN,
CorePlugin.Util.getString(LogMessageKeys.ADMIN_0016, token.getUsername()));
-
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_PRODUCT,
"RuntimeStateAdminAPIImpl.bounceServer()"); //$NON-NLS-1$
-
-
- helper.bounceServer();
- }
-
-
- /**
* Restart a failed or stopped service.
*
* @param serviceID
Deleted:
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/SessionAdminAPIImpl.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/SessionAdminAPIImpl.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/SessionAdminAPIImpl.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -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 com.metamatrix.platform.admin.apiimpl;
-
-import java.util.Collection;
-
-import org.teiid.dqp.internal.process.DQPWorkContext;
-
-import com.metamatrix.admin.api.exception.security.InvalidSessionException;
-import com.metamatrix.admin.api.server.AdminRoles;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.security.AuthorizationException;
-import com.metamatrix.api.exception.security.SessionServiceException;
-import com.metamatrix.platform.admin.api.SessionAdminAPI;
-import com.metamatrix.platform.security.api.MetaMatrixPrincipal;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.SessionToken;
-import com.metamatrix.platform.security.api.service.SessionServiceInterface;
-import com.metamatrix.platform.util.PlatformProxyHelper;
-
-public class SessionAdminAPIImpl extends SubSystemAdminAPIImpl implements SessionAdminAPI
{
-
- // Auth svc proxy
- private SessionServiceInterface sessAdmin;
- private static SessionAdminAPI sessionAdminAPI;
-
- /**
- * ctor
- */
- private SessionAdminAPIImpl() {
-
- sessAdmin =
PlatformProxyHelper.getSessionServiceProxy(PlatformProxyHelper.ROUND_ROBIN_LOCAL);
- }
-
- public synchronized static SessionAdminAPI getInstance() {
- if (sessionAdminAPI == null) {
- sessionAdminAPI = new SessionAdminAPIImpl();
- }
- return sessionAdminAPI;
- }
-
- /**
- * Get the information for the account to which the specified session has been
authenticated.
- *
- * @param userSessionID ID identifying session for which the account information is
to be obtained
- * @return the information for the user account for which the
<code>sessionToken</code> is logged into
- * @throws InvalidSessionException If the caller's session has expired or
doesn't exist
- * @throws SessionNotFoundException If specified
<code>userSessionID</code> is invalid or nonexistant
- * @throws AuthorizationException if the caller denoted by
<code>callerSessionID</code>
- * does not have authority to access the account information for the
<code>userSessionID</code> session
- * @throws MetaMatrixComponentException If couldn't find a component
- */
- public synchronized MetaMatrixPrincipal getPrincipal(MetaMatrixSessionID
userSessionID)
- throws InvalidSessionException, AuthorizationException, MetaMatrixComponentException,
SessionServiceException {
- return sessAdmin.getPrincipal(userSessionID);
- }
-
- public synchronized Collection getActiveSessions()
- throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException,
SessionServiceException {
- return sessAdmin.getActiveSessions();
- }
-
- public synchronized void terminateSession(MetaMatrixSessionID userSessionID)
- throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException,
SessionServiceException {
- // Validate caller's session
- SessionToken token = DQPWorkContext.getWorkContext().getSessionToken();
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_SYSTEM,
"SessionAdminAPIImpl.terminateSession(" + userSessionID + ")");
//$NON-NLS-1$ //$NON-NLS-2$
- sessAdmin.terminateSession(userSessionID, getSessionID());
- }
-
- public synchronized Boolean isSessionValid(MetaMatrixSessionID userSessionID)
- throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException,
SessionServiceException {
- // Any administrator may call this read-only method - no need to validate role
- try {
- sessAdmin.validateSession(userSessionID);
- return Boolean.TRUE;
- } catch (InvalidSessionException e) {
-
- }
- return Boolean.FALSE;
- }
-
- /**
- * Get the count of active user sessions on the system.
- * @return The count of all active users on
- * the system.
- */
- public synchronized int getActiveSessionsCount()
- throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException,
SessionServiceException {
- return sessAdmin.getActiveSessionsCount();
- }
-
- /**
- * Get the count of all active connections to a product.
- * @return The count of all active connections to a product on
- * the system.
- */
- public synchronized int getActiveConnectionsCountForProduct(String product)
- throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException,
SessionServiceException {
- return sessAdmin.getActiveConnectionsCountForProduct(product);
- }
-
-}
-
Modified:
trunk/server/src/main/java/com/metamatrix/platform/config/api/service/ConfigurationServiceInterface.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/config/api/service/ConfigurationServiceInterface.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/server/src/main/java/com/metamatrix/platform/config/api/service/ConfigurationServiceInterface.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -267,18 +267,6 @@
*/
void saveResources(Collection resourceDescriptors, String principalName) throws
ConfigurationException;
-
-
- /**
- * Obtain the List of {@link com.metamatrix.common.config.api.ReleaseInfo} objects
which represent the products of the system.
- * Each ReleaseInfo contains the name of the product, as well as release info.
- *
- * @return Collection of ReleaseInfo objects of licensed products.
- * @throws ConfigurationException
- * if an business error occurred within or during communication with the
Configuration Service.
- */
- Collection getProductReleaseInfos() throws ConfigurationException;
-
// --------------------------------------------------------------
// A C T I O N M E T H O D S
// --------------------------------------------------------------
Modified:
trunk/server/src/main/java/com/metamatrix/platform/config/service/ConfigurationServiceImpl.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/config/service/ConfigurationServiceImpl.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/server/src/main/java/com/metamatrix/platform/config/service/ConfigurationServiceImpl.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -55,7 +55,6 @@
import com.metamatrix.common.config.api.HostID;
import com.metamatrix.common.config.api.ProductServiceConfig;
import com.metamatrix.common.config.api.ProductServiceConfigID;
-import com.metamatrix.common.config.api.ReleaseInfo;
import com.metamatrix.common.config.api.ServiceComponentDefnID;
import com.metamatrix.common.config.api.VMComponentDefn;
import com.metamatrix.common.config.api.VMComponentDefnID;
@@ -67,7 +66,6 @@
import com.metamatrix.common.config.xml.XMLConfigurationImportExportUtility;
import com.metamatrix.common.log.I18nLogManager;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.ApplicationInfo;
import com.metamatrix.common.util.LogCommonConstants;
import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.platform.PlatformPlugin;
@@ -570,22 +568,6 @@
transaction.commit(); // commit the transaction
}
- /**
- * Obtain the List of {@link com.metamatrix.common.config.api.ReleaseInfo} objects
- * which represent the products of the system. Each ReleaseInfo contains
- * the name of the product, as well as release info.
- * @return Collection of ReleaseInfo objects of licensed products.
- * @throws ConfigurationException if an business error occurred within or during
communication with the Configuration Service.
- */
- public Collection getProductReleaseInfos() throws ConfigurationException {
- ApplicationInfo build = ApplicationInfo.getInstance();
- ReleaseInfo info = new ReleaseInfo("Server", build.getReleaseNumber(),
build.getBuildDate(), build.getBuildNumber()); //$NON-NLS-1$
- List l = new ArrayList();
- l.add(info);
- return l;
- }
-
-
// --------------------------------------------------------------
// A C T I O N M E T H O D S
// --------------------------------------------------------------
Copied:
trunk/server/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java
(from rev 713,
trunk/client/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java)
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java
(rev 0)
+++
trunk/server/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -0,0 +1,162 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+import java.util.Properties;
+
+/**
+ * This class represents an immutable informational object describing
+ * the attributes of a unique MetaMatrix session within a given MetaMatrix System.
+ */
+public class MetaMatrixSessionInfo implements Serializable, Cloneable {
+
+ public final static long serialVersionUID = -9120197553960136239L;
+
+ private SessionToken sessionToken; // immutable
+ private long lastPingTime;
+ private long timeCreated;
+ private String applicationName;
+ private String product;
+ private Properties productInfo;
+ private String clientIp;
+ private String clientHostname;
+ private Serializable trustedToken;
+
+ /**
+ * Master constructor, allows a MetaMatrixSessionInfo to be created with
+ * any state and any timestamps.
+ */
+ public MetaMatrixSessionInfo(MetaMatrixSessionID sessionID, String userName, long
timeCreated, String applicationName, Properties productInfo, String product, String
clientIp, String clientHostname){
+ this.timeCreated = timeCreated;
+ this.lastPingTime = timeCreated;
+ this.applicationName = applicationName;
+ this.product = product;
+ this.sessionToken = new SessionToken(sessionID, userName);
+ this.productInfo = productInfo;
+ this.clientIp = clientIp;
+ this.clientHostname = clientHostname;
+ }
+
+ public MetaMatrixSessionID getSessionID() {
+ return this.sessionToken.getSessionID();
+ }
+
+ public String getUserName() {
+ return this.sessionToken.getUsername();
+ }
+
+ public String getApplicationName() {
+ return this.applicationName;
+ }
+
+ public long getTimeCreated() {
+ return this.timeCreated;
+ }
+
+ /**
+ * Get the time the server was last pinged by this session.
+ * Note that the session's "last ping time" will only be acurate
+ * if the session is in the ACTIVE state.
+ * @return The time the server was last pinged by this session.
+ */
+ public long getLastPingTime() {
+ return lastPingTime;
+ }
+
+ /**
+ * Used <i><b>ONLY</b></i> by the session service to set the
+ * time this session last initiated a server ping.
+ * @param lastPingTime The last time this session pinged the server.
+ */
+ public void setLastPingTime(long lastPingTime) {
+ this.lastPingTime = lastPingTime;
+ }
+
+ public String getProductName() {
+ return this.product;
+ }
+
+ public SessionToken getSessionToken(){
+ return this.sessionToken;
+ }
+
+ /**
+ * Return a cloned instance of this object.
+ * @return the object that is the clone of this instance.
+ */
+ public Object clone() {
+ try {
+ // Everything is immutable, so bit-wise copy (of references) is okay!
+ return super.clone();
+ } catch ( CloneNotSupportedException e ) {
+ }
+ return null;
+ }
+
+ /**
+ * Returns a string representing the current state of the object.
+ */
+ public String toString() {
+ StringBuffer s = new StringBuffer();
+ s.append("MetaMatrixSessionInfo[ "); //$NON-NLS-1$
+ s.append(this.sessionToken.toString());
+ s.append(", "); //$NON-NLS-1$
+ s.append("application:"); //$NON-NLS-1$
+ s.append(this.applicationName);
+ s.append(", created:"); //$NON-NLS-1$
+ s.append(this.timeCreated);
+ s.append(", last pinged server:"); //$NON-NLS-1$
+ s.append(this.lastPingTime);
+ s.append("]"); //$NON-NLS-1$
+ return s.toString();
+ }
+
+ /**
+ * @return Returns the productInfo.
+ * @since 4.3
+ */
+ public String getProductInfo(String key) {
+ return this.productInfo.getProperty(key);
+ }
+
+ public Properties getProductInfo() {
+ return this.productInfo;
+ }
+
+ public String getClientIp() {
+ return clientIp;
+ }
+
+ public String getClientHostname() {
+ return clientHostname;
+ }
+
+ public void setTrustedToken(Serializable trustedToken) {
+ this.trustedToken = trustedToken;
+ }
+
+ public Serializable getTrustedToken() {
+ return trustedToken;
+ }
+}
Property changes on:
trunk/server/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified:
trunk/server/src/main/java/com/metamatrix/platform/security/api/service/SessionServiceInterface.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/security/api/service/SessionServiceInterface.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/server/src/main/java/com/metamatrix/platform/security/api/service/SessionServiceInterface.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -56,7 +56,7 @@
*/
public interface SessionServiceInterface extends ServiceInterface {
public static String NAME = "SessionService"; //$NON-NLS-1$
-
+
/**
* Create a session for the given user authenticating against the given
<code>Credentials</code>.
*/
@@ -109,13 +109,6 @@
int getActiveSessionsCount() throws SessionServiceException;
/**
- * Get the number of active connections for the product.
- * @param product String name of product
- * @return int
- */
- int getActiveConnectionsCountForProduct(String product) throws
SessionServiceException;
-
- /**
* Returns a MetaMatrixPrincipal object describing the owner (user) of the
* indicated session.
* @param sessionID MetaMatrixSessionID representing the session
Modified:
trunk/server/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/server/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -47,6 +47,8 @@
import com.metamatrix.common.comm.api.ServerConnection;
import com.metamatrix.common.config.CurrentConfiguration;
import com.metamatrix.common.config.api.Configuration;
+import com.metamatrix.common.id.dbid.DBIDController;
+import com.metamatrix.common.id.dbid.DBIDGenerator;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.MetaMatrixProductNames;
import com.metamatrix.common.util.PropertiesUtils;
@@ -83,7 +85,7 @@
SessionServiceInterface {
/**
- * Comma delimeted string containing a list of SessionTerminationHandlers to be
called when a session
+ * Comma delimited string containing a list of SessionTerminationHandlers to be
called when a session
* is terminated.
*/
private static final String SESSION_TERMINATION_HANDLERS =
"security.session.terminationHandlers"; //$NON-NLS-1$
@@ -91,6 +93,8 @@
private static final String SESSION_TIME_LIMIT =
"metamatrix.session.time.limit"; //$NON-NLS-1$
public static final String SESSION_MONITOR_ACTIVITY_INTERVAL =
"metamatrix.session.sessionMonitor.ActivityInterval"; //$NON-NLS-1$
+ private static final String SESSION_ID = "SESSION_ID"; //$NON-NLS-1$
+
private MembershipServiceInterface membershipService;
private Cache<MetaMatrixSessionID, MetaMatrixSessionInfo> sessionCache;
private long sessionMaxLimit;
@@ -100,6 +104,7 @@
private Map<String, SessionTerminationHandler> terminationHandlerMap = new
HashMap<String, SessionTerminationHandler>();
private Timer sessionMonitor;
+ private DBIDController idGenerator = DBIDGenerator.getInstance();
//
-----------------------------------------------------------------------------------
// S E R V I C E - R E L A T E D M E T H O D S
@@ -258,7 +263,7 @@
// Get a new ID for this new session record
- MetaMatrixSessionID id = new MetaMatrixSessionID();
+ MetaMatrixSessionID id = new MetaMatrixSessionID(getUniqueSessionID());
// Return a new session info object
MetaMatrixSessionInfo newSession = new MetaMatrixSessionInfo(id,
@@ -270,17 +275,22 @@
properties.getProperty(MMURL.CONNECTION.CLIENT_IP_ADDRESS),
properties.getProperty(MMURL.CONNECTION.CLIENT_HOSTNAME));
newSession.setTrustedToken(trustedToken);
- if (this.sessionCache.put(newSession.getSessionID(), newSession) != null) {
- try {
- this.closeSession(newSession.getSessionID());
- } catch (InvalidSessionException e) {
- LogManager.logDetail(LogSecurityConstants.CTX_SESSION, e, "Error closing
invalidated session"); //$NON-NLS-1$
- }
- throw new AssertionError("duplicate session id"); //$NON-NLS-1$
- }
+ this.sessionCache.put(newSession.getSessionID(), newSession);
return newSession;
}
+ public void setIdGenerator(DBIDController idGenerator) {
+ this.idGenerator = idGenerator;
+ }
+
+ private long getUniqueSessionID() throws SessionServiceException {
+ try {
+ return idGenerator.getID(SESSION_ID);
+ } catch (Exception e) {
+ throw new SessionServiceException(ErrorMessageKeys.SEC_SESSION_0107,
PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_SESSION_0107));
+ }
+ }
+
private AuthenticationToken authenticateUser(String userName,
Credentials credentials, Serializable trustedToken,
String applicationName) throws SessionServiceException,
@@ -288,7 +298,7 @@
AuthenticationToken authenticatedToken = null;
// Authenticate the principal ...
try {
- authenticatedToken = (AuthenticationToken)
this.membershipService.authenticateUser(userName,
+ authenticatedToken = this.membershipService.authenticateUser(userName,
credentials, trustedToken, applicationName);
} catch (ServiceException e) {
String msg = PlatformPlugin.Util
@@ -317,21 +327,6 @@
}
@Override
- public int getActiveConnectionsCountForProduct(String product)
- throws SessionServiceException {
- if (product == null) {
- return 0;
- }
- int result = 0;
- for (MetaMatrixSessionInfo info : this.sessionCache.values()) {
- if (product.equalsIgnoreCase(info.getProductName())) {
- result++;
- }
- }
- return result;
- }
-
- @Override
public Collection<MetaMatrixSessionInfo> getActiveSessions() throws
SessionServiceException {
return new ArrayList<MetaMatrixSessionInfo>(this.sessionCache.values());
}
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-04-06
14:29:25 UTC (rev 718)
+++
trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -85,14 +85,12 @@
import com.metamatrix.platform.admin.api.ExtensionSourceAdminAPI;
import com.metamatrix.platform.admin.api.MembershipAdminAPI;
import com.metamatrix.platform.admin.api.RuntimeStateAdminAPI;
-import com.metamatrix.platform.admin.api.SessionAdminAPI;
import com.metamatrix.platform.admin.apiimpl.AdminHelper;
import com.metamatrix.platform.admin.apiimpl.AuthorizationAdminAPIImpl;
import com.metamatrix.platform.admin.apiimpl.ConfigurationAdminAPIImpl;
import com.metamatrix.platform.admin.apiimpl.ExtensionSourceAdminAPIImpl;
import com.metamatrix.platform.admin.apiimpl.MembershipAdminAPIImpl;
import com.metamatrix.platform.admin.apiimpl.RuntimeStateAdminAPIImpl;
-import com.metamatrix.platform.admin.apiimpl.SessionAdminAPIImpl;
import com.metamatrix.platform.config.api.service.ConfigurationServiceInterface;
import com.metamatrix.platform.config.event.ConfigurationChangeEvent;
import com.metamatrix.platform.registry.ClusteredRegistryState;
@@ -128,6 +126,8 @@
* configured under this server
*/
public abstract class ProcessController implements ProcessManagement {
+
+ public final static String SERVICE_ID = "Service"; //$NON-NLS-1$
public static final String STARTER_MAX_THREADS = "vm.starter.maxThreads";
//$NON-NLS-1$
/**Time-to-live for threads used to start services (ms)*/
@@ -213,7 +213,6 @@
this.clientServices.registerClientService(ConfigurationAdminAPI.class,
ConfigurationAdminAPIImpl.getInstance(this.registry),
PlatformAdminConstants.CTX_CONFIGURATION_ADMIN_API);
this.clientServices.registerClientService(RuntimeStateAdminAPI.class,
RuntimeStateAdminAPIImpl.getInstance(this.registry, hostManagement),
PlatformAdminConstants.CTX_RUNTIME_STATE_ADMIN_API);
this.clientServices.registerClientService(MembershipAdminAPI.class,
MembershipAdminAPIImpl.getInstance(), PlatformAdminConstants.CTX_ADMIN_API);
- this.clientServices.registerClientService(SessionAdminAPI.class,
SessionAdminAPIImpl.getInstance(), PlatformAdminConstants.CTX_ADMIN_API);
this.clientServices.registerClientService(AuthorizationAdminAPI.class,
AuthorizationAdminAPIImpl.getInstance(),
PlatformAdminConstants.CTX_AUTHORIZATION_ADMIN_API);
this.clientServices.registerClientService(ExtensionSourceAdminAPI.class,
ExtensionSourceAdminAPIImpl.getInstance(), PlatformAdminConstants.CTX_ADMIN_API);
this.clientServices.registerClientService(QueryAdminAPI.class,
QueryAdminAPIImpl.getInstance(), PlatformAdminConstants.CTX_ADMIN_API);
@@ -930,7 +929,7 @@
*/
private ServiceID createServiceID() {
try {
- return new
ServiceID(DBIDGenerator.getInstance().getID(DBIDGenerator.SERVICE_ID), host.getFullName(),
this.processName);
+ return new ServiceID(DBIDGenerator.getInstance().getID(SERVICE_ID),
host.getFullName(), this.processName);
} catch (DBIDGeneratorException e) {
throw new ServiceException(e, ErrorMessageKeys.SERVICE_0025,
PlatformPlugin.Util.getString(ErrorMessageKeys.SERVICE_0025));
}
Modified:
trunk/server/src/test/java/com/metamatrix/admin/server/TestServerMonitoringAdminImpl.java
===================================================================
---
trunk/server/src/test/java/com/metamatrix/admin/server/TestServerMonitoringAdminImpl.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/server/src/test/java/com/metamatrix/admin/server/TestServerMonitoringAdminImpl.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -33,6 +33,7 @@
import com.metamatrix.admin.api.exception.AdminException;
import com.metamatrix.admin.api.objects.AdminObject;
import com.metamatrix.admin.api.objects.ConnectorBinding;
+import com.metamatrix.admin.api.objects.Session;
import com.metamatrix.admin.objects.MMConnectorBinding;
import com.metamatrix.admin.objects.MMConnectorType;
import com.metamatrix.admin.objects.MMDQP;
@@ -463,11 +464,11 @@
* @since 4.3
*/
public void testGetSessions() throws AdminException {
- Collection results = admin.getSessions(AdminObject.WILDCARD);
+ Collection<Session> results = admin.getSessions(AdminObject.WILDCARD);
assertEquals(2, results.size());
MMSession session = (MMSession) results.iterator().next();
- assertEquals("00000000-0000-0001-0000-000000000001",
session.getIdentifier()); //$NON-NLS-1$
+ assertEquals("1", session.getIdentifier()); //$NON-NLS-1$
assertEquals("vdb1", session.getVDBName()); //$NON-NLS-1$
assertEquals("1", session.getVDBVersion()); //$NON-NLS-1$
assertEquals("app1", session.getApplicationName()); //$NON-NLS-1$
@@ -475,7 +476,7 @@
- results = admin.getSessions("00000000-0000-0001-0000-000000000001");
//$NON-NLS-1$
+ results = admin.getSessions("1"); //$NON-NLS-1$
assertEquals(1, results.size());
}
Modified:
trunk/server/src/test/java/com/metamatrix/admin/server/TestServerRuntimeStateAdminImpl.java
===================================================================
---
trunk/server/src/test/java/com/metamatrix/admin/server/TestServerRuntimeStateAdminImpl.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/server/src/test/java/com/metamatrix/admin/server/TestServerRuntimeStateAdminImpl.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -48,12 +48,8 @@
public void setUp() throws Exception {
- System.setProperty("metamatrix.config.none", "true");
//$NON-NLS-1$ //$NON-NLS-2$
- System.setProperty("metamatrix.message.bus.type",
"noop.message.bus"); //$NON-NLS-1$ //$NON-NLS-2$
-
DBIDGenerator.getInstance().setUseMemoryIDGeneration(true);
-
FakeQueryService.clearState();
FakeCacheAdmin.clearState();
FakeRuntimeStateAdminAPIHelper.clearState();
@@ -404,9 +400,9 @@
//positive case
assertTrue(FakeServerSessionService.terminatedSessions.isEmpty());
- admin.terminateSession("00000000-0000-0001-0000-000000000001");
//$NON-NLS-1$
+ admin.terminateSession("1"); //$NON-NLS-1$
-
assertTrue(FakeServerSessionService.terminatedSessions.contains("00000000-0000-0001-0000-000000000001"));
//$NON-NLS-1$
+ assertTrue(FakeServerSessionService.terminatedSessions.contains("1"));
//$NON-NLS-1$
//failure case: invalid session ID
boolean failed = false;
Modified:
trunk/server/src/test/java/com/metamatrix/common/comm/platform/socket/server/TestSocketRemoting.java
===================================================================
---
trunk/server/src/test/java/com/metamatrix/common/comm/platform/socket/server/TestSocketRemoting.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/server/src/test/java/com/metamatrix/common/comm/platform/socket/server/TestSocketRemoting.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -29,10 +29,9 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-
import junit.framework.TestCase;
+import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -58,7 +57,7 @@
import com.metamatrix.dqp.client.ResultsFuture;
import com.metamatrix.platform.security.api.ILogon;
import com.metamatrix.platform.security.api.LogonResult;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
+import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.platform.security.api.service.SessionServiceInterface;
public class TestSocketRemoting extends TestCase {
@@ -150,7 +149,7 @@
public ResultsFuture<?> logoff()
throws InvalidSessionException,
MetaMatrixComponentException {
- ResultsFuture<?> result = new ResultsFuture();
+ ResultsFuture<?> result = new ResultsFuture<Void>();
result.getResultsReceiver().exceptionOccurred(new
MetaMatrixComponentException("some exception")); //$NON-NLS-1$
return result;
}
@@ -165,15 +164,15 @@
MetaMatrixComponentException {
return null;
}
-
+
@Override
- public void assertIdentity(MetaMatrixSessionID sessionId)
- throws InvalidSessionException,
- MetaMatrixComponentException {
-
+ public void assertIdentity(SessionToken sessionId)
+ throws InvalidSessionException,
+ MetaMatrixComponentException {
}
- }, "foo");
- csr.registerClientService(FakeService.class, new FakeServiceImpl(), "foo");
+
+ }, "foo"); //$NON-NLS-1$
+ csr.registerClientService(FakeService.class, new FakeServiceImpl(), "foo");
//$NON-NLS-1$
final FakeClientServerInstance serverInstance = new FakeClientServerInstance(csr);
SocketServerConnection connection = createFakeConnection(serverInstance);
ILogon logon = connection.getService(ILogon.class);
Modified:
trunk/server/src/test/java/com/metamatrix/platform/security/session/service/TestSessionServiceImpl.java
===================================================================
---
trunk/server/src/test/java/com/metamatrix/platform/security/session/service/TestSessionServiceImpl.java 2009-04-06
14:29:25 UTC (rev 718)
+++
trunk/server/src/test/java/com/metamatrix/platform/security/session/service/TestSessionServiceImpl.java 2009-04-06
15:32:15 UTC (rev 719)
@@ -8,6 +8,7 @@
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
import com.metamatrix.cache.FakeCache;
+import com.metamatrix.common.id.dbid.spi.InMemoryIDController;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
import com.metamatrix.platform.security.api.service.MembershipServiceInterface;
@@ -17,6 +18,7 @@
public void testValidateSession() throws Exception {
SessionServiceImpl ssi = new SessionServiceImpl();
+ ssi.setIdGenerator(new InMemoryIDController());
ssi.setSessionCache(new FakeCache<MetaMatrixSessionID,
MetaMatrixSessionInfo>());
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$
@@ -35,8 +37,6 @@
ssi.validateSession(id1);
assertEquals(1, ssi.getActiveSessionsCount());
- assertEquals(0, ssi.getActiveConnectionsCountForProduct("x")); //$NON-NLS-1$
- assertEquals(1, ssi.getActiveConnectionsCountForProduct("test"));
//$NON-NLS-1$
assertEquals(0, ssi.getSessionsLoggedInToVDB("a", "1").size());
//$NON-NLS-1$ //$NON-NLS-2$
ssi.closeSession(id1);