Author: shawkins
Date: 2010-04-22 14:55:02 -0400 (Thu, 22 Apr 2010)
New Revision: 2073
Added:
trunk/client/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java
trunk/client/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java
Modified:
trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
trunk/adminshell/src/main/java/org/teiid/adminshell/Help.java
trunk/client/src/main/java/org/teiid/adminapi/Admin.java
trunk/client/src/main/java/org/teiid/adminapi/Request.java
trunk/client/src/main/java/org/teiid/adminapi/Session.java
trunk/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java
trunk/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java
trunk/client/src/main/java/org/teiid/adminapi/impl/RequestMetadataMapper.java
trunk/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
trunk/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java
trunk/client/src/main/java/org/teiid/client/security/LogonResult.java
trunk/client/src/main/java/org/teiid/client/security/SessionToken.java
trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java
trunk/client/src/test/java/org/teiid/net/socket/TestSocketServerConnection.java
trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/SessionService.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.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/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java
trunk/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java
trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.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/TestPreparedStatement.java
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java
trunk/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java
trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java
trunk/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java
trunk/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java
trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
Log:
TEIID-207 TEIID-1057 switching to a string based session id and fixing issues with the
mapping of session and request metadata
Modified: trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java 2010-04-22
17:22:34 UTC (rev 2072)
+++ trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -146,7 +146,7 @@
@Doc(text = "Cancel a request")
public static void cancelRequest(
- @Doc(text = "session id") long sessionId,
+ @Doc(text = "session id") String sessionId,
@Doc(text = "request id") long requestId)
throws AdminException {
getAdmin().cancelRequest(sessionId, requestId);
@@ -246,7 +246,7 @@
@Doc(text = "Get all Request instances for the given session")
public static Collection<Request> getRequestsForSession(
- @Doc(text = "session id") long sessionId)
+ @Doc(text = "session id") String sessionId)
throws AdminException {
return getAdmin().getRequestsForSession(sessionId);
}
@@ -323,7 +323,7 @@
@Doc(text = "Terminate a session and associated requests")
public static void terminateSession(
- @Doc(text = "session id") long sessionId) throws AdminException {
+ @Doc(text = "session id") String sessionId) throws AdminException {
getAdmin().terminateSession(sessionId);
}
Modified: trunk/adminshell/src/main/java/org/teiid/adminshell/Help.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/adminshell/Help.java 2010-04-22 17:22:34 UTC
(rev 2072)
+++ trunk/adminshell/src/main/java/org/teiid/adminshell/Help.java 2010-04-22 18:55:02 UTC
(rev 2073)
@@ -68,9 +68,9 @@
shortSb.append(")"); //$NON-NLS-1$
String shortHelpStr = String.format(" %-25s", shortSb.toString());
//$NON-NLS-1$
if (doc != null) {
- sb.append("/*\n *").append(doc.text()); //$NON-NLS-1$
+ sb.append("/*\n ").append(doc.text()); //$NON-NLS-1$
for (String string : doc.moreText()) {
- sb.append("\n *").append(string); //$NON-NLS-1$
+ sb.append("\n ").append(string); //$NON-NLS-1$
}
sb.append("\n */\n"); //$NON-NLS-1$
shortHelpStr += " -- " + doc.text(); //$NON-NLS-1$
Modified: trunk/client/src/main/java/org/teiid/adminapi/Admin.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/Admin.java 2010-04-22 17:22:34 UTC (rev
2072)
+++ trunk/client/src/main/java/org/teiid/adminapi/Admin.java 2010-04-22 18:55:02 UTC (rev
2073)
@@ -244,7 +244,7 @@
* @return Collection of {@link Request}
* @throws AdminException
*/
- Collection<Request> getRequestsForSession(long sessionId) throws
AdminException;
+ Collection<Request> getRequestsForSession(String sessionId) throws
AdminException;
/**
@@ -307,7 +307,7 @@
* No wild cards currently supported, must be explicit
* @throws AdminException
*/
- void terminateSession(long sessionId) throws AdminException;
+ void terminateSession(String sessionId) throws AdminException;
/**
* Cancel Request
@@ -317,7 +317,7 @@
*
* @throws AdminException
*/
- void cancelRequest(long sessionId, long requestId) throws AdminException;
+ void cancelRequest(String sessionId, long requestId) throws AdminException;
/**
* Mark the given global transaction as rollback only.
Modified: trunk/client/src/main/java/org/teiid/adminapi/Request.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/Request.java 2010-04-22 17:22:34 UTC
(rev 2072)
+++ trunk/client/src/main/java/org/teiid/adminapi/Request.java 2010-04-22 18:55:02 UTC
(rev 2073)
@@ -51,9 +51,9 @@
/**
* Get the SessionID for a Request
*
- * @return long SessionID
+ * @return String SessionID
*/
- public long getSessionId();
+ public String getSessionId();
/**
* Get the SQL Command sent to the Server for a Request
Modified: trunk/client/src/main/java/org/teiid/adminapi/Session.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/Session.java 2010-04-22 17:22:34 UTC
(rev 2072)
+++ trunk/client/src/main/java/org/teiid/adminapi/Session.java 2010-04-22 18:55:02 UTC
(rev 2073)
@@ -52,7 +52,7 @@
*
* @return String of the Session ID
*/
- public long getSessionId();
+ public String getSessionId();
/**
* Get User Name for this Session
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java 2010-04-22
17:22:34 UTC (rev 2072)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -31,8 +31,8 @@
List<RequestMetadata> getRequestsForSession(long sessionId) ;
List<RequestMetadata> getRequests();
WorkerPoolStatisticsMetadata getWorkManagerStatistics(String identifier);
- void terminateSession(long terminateeId);
- boolean cancelRequest(long sessionId, long requestId) throws AdminException;
+ void terminateSession(String terminateeId);
+ boolean cancelRequest(String sessionId, long requestId) throws AdminException;
Collection<String> getCacheTypes();
void clearCache(String cacheType);
Collection<SessionMetadata> getActiveSessions() throws AdminException;
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java 2010-04-22
17:22:34 UTC (rev 2072)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -37,7 +37,7 @@
private static final long serialVersionUID = -2779106368517784259L;
private long executionId;
- private long sessionId;
+ private String sessionId;
private String command;
private long startTime;
private boolean sourceRequest;
@@ -67,11 +67,11 @@
@Override
@ManagementProperty(description="Session ID", readOnly=true)
- public long getSessionId() {
+ public String getSessionId() {
return this.sessionId;
}
- public void setSessionId(long session) {
+ public void setSessionId(String session) {
this.sessionId = session;
}
@@ -111,7 +111,7 @@
return this.nodeID;
}
- public void setNodeId(int nodeID) {
+ public void setNodeId(Integer nodeID) {
this.nodeID = nodeID;
}
@@ -138,7 +138,7 @@
}
public int hashCode() {
- return HashCodeUtil.hashCode((int)executionId, (int)sessionId);
+ return HashCodeUtil.hashCode((int)executionId, sessionId);
}
@SuppressWarnings("nls")
@@ -146,7 +146,7 @@
StringBuilder str = new StringBuilder();
str.append("Request: sessionid=").append(sessionId);
str.append("; executionId=").append(executionId);
- if (nodeID != Integer.MIN_VALUE) {
+ if (nodeID != null) {
str.append("; nodeId=").append(nodeID);
}
if (transactionId != null) {
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/RequestMetadataMapper.java
===================================================================
---
trunk/client/src/main/java/org/teiid/adminapi/impl/RequestMetadataMapper.java 2010-04-22
17:22:34 UTC (rev 2072)
+++
trunk/client/src/main/java/org/teiid/adminapi/impl/RequestMetadataMapper.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -24,15 +24,18 @@
import java.lang.reflect.Type;
import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.EnumMetaType;
import org.jboss.metatype.api.types.MetaType;
import org.jboss.metatype.api.types.SimpleMetaType;
import org.jboss.metatype.api.values.CompositeValue;
import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.EnumValueSupport;
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.MetaValueFactory;
import org.jboss.metatype.api.values.SimpleValueSupport;
import org.jboss.metatype.plugins.types.MutableCompositeMetaType;
import org.jboss.metatype.spi.values.MetaMapper;
+import org.teiid.adminapi.Request;
import org.teiid.adminapi.Request.State;
public class RequestMetadataMapper extends MetaMapper<RequestMetadata> {
@@ -40,8 +43,7 @@
private static final String NODE_ID = "nodeId"; //$NON-NLS-1$
private static final String SOURCE_REQUEST = "sourceRequest"; //$NON-NLS-1$
private static final String COMMAND = "command"; //$NON-NLS-1$
- private static final String PROCESSING_TIME = "startTime"; //$NON-NLS-1$
- private static final String CREATED_TIME = "createdTime"; //$NON-NLS-1$
+ private static final String START_TIME = "startTime"; //$NON-NLS-1$
private static final String SESSION_ID = "sessionId"; //$NON-NLS-1$
private static final String EXECUTION_ID = "executionId"; //$NON-NLS-1$
private static final String STATE = "state"; //$NON-NLS-1$
@@ -51,14 +53,14 @@
static {
metaType = new MutableCompositeMetaType(RequestMetadata.class.getName(), "The
Request meta data"); //$NON-NLS-1$
metaType.addItem(EXECUTION_ID, EXECUTION_ID, SimpleMetaType.LONG_PRIMITIVE);
- metaType.addItem(SESSION_ID, SESSION_ID, SimpleMetaType.LONG_PRIMITIVE);
- metaType.addItem(CREATED_TIME, CREATED_TIME, SimpleMetaType.LONG_PRIMITIVE);
- metaType.addItem(PROCESSING_TIME, PROCESSING_TIME, SimpleMetaType.LONG_PRIMITIVE);
+ metaType.addItem(SESSION_ID, SESSION_ID, SimpleMetaType.STRING);
+ metaType.addItem(START_TIME, START_TIME, SimpleMetaType.LONG_PRIMITIVE);
metaType.addItem(COMMAND, COMMAND, SimpleMetaType.STRING);
metaType.addItem(SOURCE_REQUEST, SOURCE_REQUEST, SimpleMetaType.BOOLEAN_PRIMITIVE);
- metaType.addItem(NODE_ID, NODE_ID, SimpleMetaType.INTEGER_PRIMITIVE);
+ metaType.addItem(NODE_ID, NODE_ID, SimpleMetaType.INTEGER);
metaType.addItem(TRANSACTION_ID, TRANSACTION_ID, SimpleMetaType.STRING);
- metaType.addItem(STATE, STATE, SimpleMetaType.STRING);
+ EnumMetaType emt = new EnumMetaType(Request.State.values());
+ metaType.addItem(STATE, STATE, emt);
metaType.freeze();
}
@@ -82,12 +84,13 @@
request.set(EXECUTION_ID, SimpleValueSupport.wrap(object.getExecutionId()));
request.set(SESSION_ID, SimpleValueSupport.wrap(object.getSessionId()));
- request.set(PROCESSING_TIME, SimpleValueSupport.wrap(object.getStartTime()));
+ request.set(START_TIME, SimpleValueSupport.wrap(object.getStartTime()));
request.set(COMMAND, SimpleValueSupport.wrap(object.getCommand()));
request.set(SOURCE_REQUEST, SimpleValueSupport.wrap(object.sourceRequest()));
request.set(NODE_ID, SimpleValueSupport.wrap(object.getNodeId()));
request.set(TRANSACTION_ID,SimpleValueSupport.wrap(object.getTransactionId()));
- request.set(STATE,SimpleValueSupport.wrap(object.getState()));
+ EnumMetaType emt = (EnumMetaType)composite.getType(STATE);
+ request.set(STATE, new EnumValueSupport(emt, object.getState()));
return request;
}
throw new IllegalArgumentException("Cannot convert RequestMetadata " +
object); //$NON-NLS-1$
@@ -103,8 +106,8 @@
RequestMetadata request = new RequestMetadata();
request.setExecutionId((Long)
metaValueFactory.unwrap(compositeValue.get(EXECUTION_ID)));
- request.setSessionId((Long) metaValueFactory.unwrap(compositeValue.get(SESSION_ID)));
- request.setStartTime((Long)
metaValueFactory.unwrap(compositeValue.get(PROCESSING_TIME)));
+ request.setSessionId((String)
metaValueFactory.unwrap(compositeValue.get(SESSION_ID)));
+ request.setStartTime((Long) metaValueFactory.unwrap(compositeValue.get(START_TIME)));
request.setCommand((String) metaValueFactory.unwrap(compositeValue.get(COMMAND)));
request.setSourceRequest((Boolean)
metaValueFactory.unwrap(compositeValue.get(SOURCE_REQUEST)));
request.setNodeId((Integer) metaValueFactory.unwrap(compositeValue.get(NODE_ID)));
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java 2010-04-22
17:22:34 UTC (rev 2072)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -48,7 +48,7 @@
private String userName;
private String vdbName;
private int vdbVersion;
- private long sessionId = -1; // invalid session
+ private String sessionId;
private String securityDomain;
//server session state
@@ -110,11 +110,11 @@
@Override
@ManagementProperty(description="Session ID", readOnly=true)
- public long getSessionId() {
+ public String getSessionId() {
return this.sessionId;
}
- public void setSessionId(long sessionId) {
+ public void setSessionId(String sessionId) {
this.sessionId = sessionId;
}
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java
===================================================================
---
trunk/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java 2010-04-22
17:22:34 UTC (rev 2072)
+++
trunk/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -55,7 +55,7 @@
metaType.addItem(CLIENT_HOST_NAME, CLIENT_HOST_NAME, SimpleMetaType.STRING);
metaType.addItem(IP_ADDRESS, IP_ADDRESS, SimpleMetaType.STRING);
metaType.addItem(LAST_PING_TIME, LAST_PING_TIME, SimpleMetaType.LONG_PRIMITIVE);
- metaType.addItem(SESSION_ID, SESSION_ID, SimpleMetaType.LONG_PRIMITIVE);
+ metaType.addItem(SESSION_ID, SESSION_ID, SimpleMetaType.STRING);
metaType.addItem(USER_NAME, USER_NAME, SimpleMetaType.STRING);
metaType.addItem(VDB_NAME, VDB_NAME, SimpleMetaType.STRING);
metaType.addItem(VDB_VERSION, VDB_VERSION, SimpleMetaType.INTEGER_PRIMITIVE);
@@ -111,7 +111,7 @@
session.setClientHostName((String)
metaValueFactory.unwrap(compositeValue.get(CLIENT_HOST_NAME)));
session.setIPAddress((String)
metaValueFactory.unwrap(compositeValue.get(IP_ADDRESS)));
session.setLastPingTime((Long)
metaValueFactory.unwrap(compositeValue.get(LAST_PING_TIME)));
- session.setSessionId((Long) metaValueFactory.unwrap(compositeValue.get(SESSION_ID)));
+ session.setSessionId((String)
metaValueFactory.unwrap(compositeValue.get(SESSION_ID)));
session.setUserName((String) metaValueFactory.unwrap(compositeValue.get(USER_NAME)));
session.setVDBName((String) metaValueFactory.unwrap(compositeValue.get(VDB_NAME)));
session.setVDBVersion((Integer)
metaValueFactory.unwrap(compositeValue.get(VDB_VERSION)));
Modified: trunk/client/src/main/java/org/teiid/client/security/LogonResult.java
===================================================================
--- trunk/client/src/main/java/org/teiid/client/security/LogonResult.java 2010-04-22
17:22:34 UTC (rev 2072)
+++ trunk/client/src/main/java/org/teiid/client/security/LogonResult.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -60,7 +60,7 @@
* @return
* @since 4.3
*/
- public long getSessionID() {
+ public String getSessionID() {
return this.sessionToken.getSessionID();
}
Modified: trunk/client/src/main/java/org/teiid/client/security/SessionToken.java
===================================================================
--- trunk/client/src/main/java/org/teiid/client/security/SessionToken.java 2010-04-22
17:22:34 UTC (rev 2072)
+++ trunk/client/src/main/java/org/teiid/client/security/SessionToken.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -26,8 +26,11 @@
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import java.util.UUID;
+import java.security.SecureRandom;
+import java.util.Arrays;
+import com.metamatrix.core.util.Base64;
+
/**
* This class is an immutable identifier for a unique session that also
* maintains the name of the principal for that session.
@@ -36,49 +39,64 @@
* transit if sent to the client. Also it should only be sent to the client
* who creates the session.
*/
-public class SessionToken implements Externalizable, Cloneable {
+public class SessionToken implements Externalizable {
public final static long serialVersionUID = -2853708320435636107L;
+ private static final SecureRandom random = new SecureRandom();
+
/** The session ID */
- private long sessionID;
+ private String sessionID;
private String userName;
- private UUID secret;
-
- /**
- * Fake SessionToken representing a trusted user
- */
+ private byte[] secret = new byte[16];
+
public SessionToken() {
- this.sessionID = -1L;
- this.userName = "trusted"; //$NON-NLS-1$
- this.secret = new UUID(1,1);
}
/**
- * The primary constructor that specifies the id, userName, and product info
- * for the session represented by this token.
+ * Used by tests to control the session id
*
* @param id
- * (long) the unique identifier for the session
* @param userName
- * (String) the userName for this session
- * @throws IllegalArgumentException
- */
+ */
public SessionToken(long id, String userName) {
- this.sessionID = id;
+ this.sessionID = Long.toString(id);
this.userName = userName;
- this.secret = UUID.randomUUID();
}
- public UUID getSecret() {
- return secret;
+ /**
+ * The primary constructor that specifies userName
+ *
+ * @param userName
+ * (String) the userName for this session
+ */
+ public SessionToken(String userName) {
+ byte[] bytes = new byte[9]; //9 bytes fits evenly into base64 and should be
sufficiently cluster unique
+ random.nextBytes(bytes);
+ this.sessionID = Base64.encodeBytes(bytes);
+ this.userName = userName;
+ random.nextBytes(secret);
}
-
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof SessionToken)) {
+ return false;
+ }
+ SessionToken other = (SessionToken)obj;
+ return userName.equals(other.userName)
+ && sessionID.equals(other.sessionID)
+ && Arrays.equals(secret, other.secret);
+ }
+
/**
* Returns unique session identifier
*
* @return the session ID
*/
- public long getSessionID() {
+ public String getSessionID() {
return this.sessionID;
}
@@ -92,76 +110,24 @@
}
/**
- * 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.
- * @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 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 == that.sessionID)
- && this.userName.equals(that.userName)
- && this.secret.equals(that.secret);
- }
-
- /**
- * Overrides Object hashCode method.
- *
- * @return a hash code value for this object.
- * @see Object#hashCode()
- * @see Object#equals(Object)
- */
- public int hashCode() {
- return new Long(this.sessionID).hashCode();
- }
-
- /**
* Returns a string representing the current state of the object.
*/
public String toString() {
return "SessionToken[" + getUsername() + "," + this.sessionID +
"]"; //$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;
- }
-
@Override
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
- secret = (UUID)in.readObject();
- sessionID = in.readLong();
+ secret = (byte[])in.readObject();
+ sessionID = (String)in.readObject();
userName = (String)in.readObject();
}
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeObject(secret);
- out.writeLong(sessionID);
+ out.writeObject(sessionID);
out.writeObject(userName);
}
Modified: trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java 2010-04-22 17:22:34 UTC
(rev 2072)
+++ trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java 2010-04-22 18:55:02 UTC
(rev 2073)
@@ -215,7 +215,7 @@
* @throws SQLException
*/
public String getConnectionId() {
- return String.valueOf(this.serverConn.getLogonResult().getSessionID());
+ return this.serverConn.getLogonResult().getSessionID();
}
long currentRequestId() {
Added: trunk/client/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java
===================================================================
--- trunk/client/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java
(rev 0)
+++ trunk/client/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi.impl;
+
+import static org.junit.Assert.*;
+
+import org.jboss.metatype.api.values.MetaValue;
+import org.junit.Test;
+import org.teiid.adminapi.Request.State;
+
+public class TestRequestMetadata {
+
+ @Test public void testMapping() {
+ RequestMetadata request = new RequestMetadata();
+ request.setState(State.PROCESSING);
+
+ RequestMetadataMapper rmm = new RequestMetadataMapper();
+ MetaValue mv = rmm.createMetaValue(rmm.getMetaType(), request);
+
+ RequestMetadata request1 = rmm.unwrapMetaValue(mv);
+
+ assertEquals(request.getState(), request1.getState());
+ }
+
+}
Property changes on:
trunk/client/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/client/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java
===================================================================
--- trunk/client/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java
(rev 0)
+++ trunk/client/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi.impl;
+
+import static org.junit.Assert.*;
+
+import org.jboss.metatype.api.values.MetaValue;
+import org.junit.Test;
+
+@SuppressWarnings("nls")
+public class TestSessionMetadata {
+
+ @Test public void testMapping() {
+ SessionMetadata session = new SessionMetadata();
+ session.setSessionId("test");
+
+ SessionMetadataMapper smm = new SessionMetadataMapper();
+ MetaValue mv = smm.createMetaValue(smm.getMetaType(), session);
+
+ SessionMetadata session1 = smm.unwrapMetaValue(mv);
+
+ assertEquals(session.getSessionId(), session1.getSessionId());
+ }
+
+}
Property changes on:
trunk/client/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/client/src/test/java/org/teiid/net/socket/TestSocketServerConnection.java
===================================================================
---
trunk/client/src/test/java/org/teiid/net/socket/TestSocketServerConnection.java 2010-04-22
17:22:34 UTC (rev 2072)
+++
trunk/client/src/test/java/org/teiid/net/socket/TestSocketServerConnection.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -84,7 +84,7 @@
Properties connectionProperties)
throws LogonException,
MetaMatrixComponentException {
- return new LogonResult(new SessionToken(1, "fooUser"), "foo", 1,
"fake"); //$NON-NLS-1$ //$NON-NLS-2$
+ return new LogonResult(new SessionToken(1, "fooUser"), "foo", 1,
"fake"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
//## JDBC4.0-begin ##
@@ -148,7 +148,7 @@
public void testLogon() throws Exception {
SocketServerConnection connection = createConnection(null);
- assertEquals(1, connection.getLogonResult().getSessionID()); //$NON-NLS-1$
+ assertEquals(String.valueOf(1), connection.getLogonResult().getSessionID());
}
/**
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java 2010-04-22
17:22:34 UTC (rev 2072)
+++
trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -87,7 +87,7 @@
public AtomicRequestMessage(RequestMessage requestMessage, DQPWorkContext parent, int
nodeId){
this.executionPayload = requestMessage.getExecutionPayload();
this.workContext = parent;
- this.requestID = new RequestID(parent.getConnectionID(),
requestMessage.getExecutionId());
+ this.requestID = new RequestID(parent.getSessionId(),
requestMessage.getExecutionId());
this.atomicRequestId = new AtomicRequestID(this.requestID, nodeId,
EXECUTION_COUNT.getAndIncrement());
}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/SessionService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/SessionService.java 2010-04-22
17:22:34 UTC (rev 2072)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/SessionService.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -78,7 +78,7 @@
* session
* @throws SessionServiceException
*/
- void closeSession(long sessionID) throws InvalidSessionException;
+ void closeSession(String sessionID) throws InvalidSessionException;
/**
* Terminates the specified session. This is an administrative action.
@@ -91,7 +91,7 @@
* does not have authority to terminate the
<code>terminatedSessionID</code> session
* @throws SessionServiceException
*/
- boolean terminateSession(long terminatedSessionID, long adminSessionID);
+ boolean terminateSession(String terminatedSessionID, String adminSessionID);
/**
* Get the collection of active user sessions on the system.
@@ -115,7 +115,7 @@
* session
* @throws SessionServiceException
*/
- SessionMetadata validateSession(long sessionID)
+ SessionMetadata validateSession(String sessionID)
throws InvalidSessionException, SessionServiceException;
/**
@@ -133,9 +133,9 @@
*
* @param sessionID - identifies the client
*/
- public void pingServer(long sessionID) throws InvalidSessionException;
+ public void pingServer(String sessionID) throws InvalidSessionException;
- SessionMetadata getActiveSession(long sessionID);
+ SessionMetadata getActiveSession(String sessionID);
void setDqp(DQPCore dqp);
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2010-04-22
17:22:34 UTC (rev 2072)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -260,10 +260,10 @@
CommandLogMessage message = null;
if (cmdStatus == Event.NEW) {
- message = new CommandLogMessage(System.currentTimeMillis(),
qr.getRequestID().toString(), id.getNodeID(), transactionID, modelName, connectorName,
qr.getWorkContext().getConnectionID(), principal, sqlStr, context);
+ message = new CommandLogMessage(System.currentTimeMillis(),
qr.getRequestID().toString(), id.getNodeID(), transactionID, modelName, connectorName,
qr.getWorkContext().getSessionId(), principal, sqlStr, context);
}
else {
- message = new CommandLogMessage(System.currentTimeMillis(),
qr.getRequestID().toString(), id.getNodeID(), transactionID, modelName, connectorName,
qr.getWorkContext().getConnectionID(), principal, finalRowCnt, cmdStatus, context);
+ message = new CommandLogMessage(System.currentTimeMillis(),
qr.getRequestID().toString(), id.getNodeID(), transactionID, modelName, connectorName,
qr.getWorkContext().getSessionId(), principal, finalRowCnt, cmdStatus, context);
}
LogManager.log(MessageLevel.DETAIL, LogConstants.CTX_COMMANDLOGGING, message);
}
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2010-04-22
17:22:34 UTC (rev 2072)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -97,7 +97,7 @@
this.securityContext = new
ExecutionContextImpl(requestMsg.getWorkContext().getVdbName(),
requestMsg.getWorkContext().getVdbVersion(),
requestMsg.getExecutionPayload(),
- requestMsg.getWorkContext().getConnectionID(),
+ requestMsg.getWorkContext().getSessionId(),
requestMsg.getConnectorName(),
requestMsg.getRequestID().toString(),
Integer.toString(requestID.getNodeID()),
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 2010-04-22
17:22:34 UTC (rev 2072)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -244,7 +244,7 @@
RequestMetadata req = new RequestMetadata();
req.setExecutionId(holder.requestID.getExecutionID());
- req.setSessionId(Long.parseLong(holder.requestID.getConnectionID()));
+ req.setSessionId(holder.requestID.getConnectionID());
req.setCommand(holder.requestMsg.getCommandString());
req.setStartTime(holder.getProcessingTimestamp());
req.setState(holder.isCanceled()?State.CANCELED:holder.isDoneProcessing()?State.DONE:State.PROCESSING);
@@ -264,7 +264,7 @@
RequestMetadata info = new RequestMetadata();
info.setExecutionId(arm.getRequestID().getExecutionID());
- info.setSessionId(Long.parseLong(holder.requestID.getConnectionID()));
+ info.setSessionId(holder.requestID.getConnectionID());
info.setCommand(arm.getCommand().toString());
info.setStartTime(arm.getProcessingTimestamp());
info.setSourceRequest(true);
@@ -288,7 +288,7 @@
} else {
request = new Request();
}
- ClientState state = this.getClientState(workContext.getConnectionID(), true);
+ ClientState state = this.getClientState(workContext.getSessionId(), true);
request.initialize(requestMsg, bufferManager,
dataTierMgr, transactionService, processorDebugAllowed,
state.tempTableStoreImpl, workContext,
@@ -322,7 +322,7 @@
void removeRequest(final RequestWorkItem workItem) {
this.requests.remove(workItem.requestID);
- ClientState state = getClientState(workItem.getDqpWorkContext().getConnectionID(),
false);
+ ClientState state = getClientState(workItem.getDqpWorkContext().getSessionId(),
false);
if (state != null) {
state.removeRequest(workItem.requestID);
}
@@ -423,9 +423,7 @@
return processWorkerPool.getStats();
}
- public void terminateSession(long terminateeId) {
- String sessionId = String.valueOf(terminateeId);
-
+ public void terminateSession(String sessionId) {
// sometimes there will not be any atomic requests pending, in that
// situation we still need to clear the master request from our map
ClientState state = getClientState(sessionId, false);
@@ -447,8 +445,8 @@
contextCache.removeSessionScopedCache(sessionId);
}
- public boolean cancelRequest(long sessionId, long requestId) throws
MetaMatrixComponentException {
- RequestID requestID = new RequestID(String.valueOf(sessionId), requestId);
+ public boolean cancelRequest(String sessionId, long requestId) throws
MetaMatrixComponentException {
+ RequestID requestID = new RequestID(sessionId, requestId);
return cancelRequest(requestID);
}
@@ -551,7 +549,7 @@
RequestMessage msg = workItem.requestMsg;
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- RequestID rID = new RequestID(workContext.getConnectionID(),
msg.getExecutionId());
+ RequestID rID = new RequestID(workContext.getSessionId(), msg.getExecutionId());
String txnID = null;
TransactionContext tc = workItem.getTransactionContext();
if (tc != null && tc.getTransactionType() != Scope.NONE) {
@@ -561,9 +559,9 @@
// Log to request log
CommandLogMessage message = null;
if (status == Event.NEW) {
- message = new CommandLogMessage(System.currentTimeMillis(), rID.toString(),
txnID, workContext.getConnectionID(), appName, workContext.getUserName(),
workContext.getVdbName(), workContext.getVdbVersion(), msg.getCommandString());
+ message = new CommandLogMessage(System.currentTimeMillis(), rID.toString(),
txnID, workContext.getSessionId(), appName, workContext.getUserName(),
workContext.getVdbName(), workContext.getVdbVersion(), msg.getCommandString());
} else {
- message = new CommandLogMessage(System.currentTimeMillis(), rID.toString(),
txnID, workContext.getConnectionID(), workContext.getUserName(), workContext.getVdbName(),
workContext.getVdbVersion(), rowCount, status);
+ message = new CommandLogMessage(System.currentTimeMillis(), rID.toString(),
txnID, workContext.getSessionId(), workContext.getUserName(), workContext.getVdbName(),
workContext.getVdbVersion(), rowCount, status);
}
LogManager.log(MessageLevel.DETAIL, LogConstants.CTX_COMMANDLOGGING, message);
}
@@ -658,14 +656,14 @@
// local txn
public ResultsFuture<?> begin() throws XATransactionException {
- String threadId = DQPWorkContext.getWorkContext().getConnectionID();
+ String threadId = DQPWorkContext.getWorkContext().getSessionId();
this.getTransactionService().begin(threadId);
return ResultsFuture.NULL_FUTURE;
}
// local txn
public ResultsFuture<?> commit() throws XATransactionException {
- final String threadId = DQPWorkContext.getWorkContext().getConnectionID();
+ final String threadId = DQPWorkContext.getWorkContext().getSessionId();
Callable<Void> processor = new Callable<Void>() {
@Override
public Void call() throws Exception {
@@ -678,7 +676,7 @@
// local txn
public ResultsFuture<?> rollback() throws XATransactionException {
- final String threadId = DQPWorkContext.getWorkContext().getConnectionID();
+ final String threadId = DQPWorkContext.getWorkContext().getSessionId();
Callable<Void> processor = new Callable<Void>() {
@Override
public Void call() throws Exception {
@@ -695,7 +693,7 @@
@Override
public Void call() throws Exception {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- getTransactionService().commit(workContext.getConnectionID(), xid, onePhase,
workContext.getSession().isEmbedded());
+ getTransactionService().commit(workContext.getSessionId(), xid, onePhase,
workContext.getSession().isEmbedded());
return null;
}
};
@@ -704,13 +702,13 @@
// global txn
public ResultsFuture<?> end(XidImpl xid, int flags) throws XATransactionException
{
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- this.getTransactionService().end(workContext.getConnectionID(), xid, flags,
workContext.getSession().isEmbedded());
+ this.getTransactionService().end(workContext.getSessionId(), xid, flags,
workContext.getSession().isEmbedded());
return ResultsFuture.NULL_FUTURE;
}
// global txn
public ResultsFuture<?> forget(XidImpl xid) throws XATransactionException {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- this.getTransactionService().forget(workContext.getConnectionID(), xid,
workContext.getSession().isEmbedded());
+ this.getTransactionService().forget(workContext.getSessionId(), xid,
workContext.getSession().isEmbedded());
return ResultsFuture.NULL_FUTURE;
}
@@ -720,7 +718,7 @@
@Override
public Integer call() throws Exception {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- return getTransactionService().prepare(workContext.getConnectionID(),xid,
workContext.getSession().isEmbedded());
+ return getTransactionService().prepare(workContext.getSessionId(),xid,
workContext.getSession().isEmbedded());
}
};
return addWork(processor);
@@ -749,7 +747,7 @@
@Override
public Void call() throws Exception {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- getTransactionService().rollback(workContext.getConnectionID(),xid,
workContext.getSession().isEmbedded());
+ getTransactionService().rollback(workContext.getSessionId(),xid,
workContext.getSession().isEmbedded());
return null;
}
};
@@ -762,7 +760,7 @@
@Override
public Void call() throws Exception {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- getTransactionService().start(workContext.getConnectionID(), xid, flags, timeout,
workContext.getSession().isEmbedded());
+ getTransactionService().start(workContext.getSessionId(), xid, flags, timeout,
workContext.getSession().isEmbedded());
return null;
}
};
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 2010-04-22
17:22:34 UTC (rev 2072)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -114,11 +114,7 @@
return session.getVDBVersion();
}
- public String getConnectionID() {
- return String.valueOf(getSessionId());
- }
-
- public long getSessionId() {
+ public String getSessionId() {
return this.session.getSessionId();
}
@@ -127,7 +123,7 @@
}
public RequestID getRequestID(long exeuctionId) {
- return new RequestID(this.getConnectionID(), exeuctionId);
+ return new RequestID(this.getSessionId(), exeuctionId);
}
public SessionToken getSessionToken() {
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2010-04-22
17:22:34 UTC (rev 2072)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -119,7 +119,7 @@
TempTableStore tempTableStore = null;
if(requestManager != null) {
if (workItem != null) {
- ClientState state =
requestManager.getClientState(workContext.getConnectionID(), false);
+ ClientState state =
requestManager.getClientState(workContext.getSessionId(), false);
if (state != null) {
tempTableStore = state.tempTableStoreImpl;
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2010-04-22
17:22:34 UTC (rev 2072)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -224,12 +224,12 @@
// Create command context, used in rewriting, planning, and processing
// Identifies a "group" of requests on a per-connection basis to allow
later
// cleanup of all resources in the group on connection shutdown
- String groupName = workContext.getConnectionID();
+ String groupName = workContext.getSessionId();
RequestID reqID = workContext.getRequestID(this.requestMsg.getExecutionId());
Properties props = new Properties();
- props.setProperty(ContextProperties.SESSION_ID, workContext.getConnectionID());
+ props.setProperty(ContextProperties.SESSION_ID, workContext.getSessionId());
this.context =
new CommandContext(
@@ -336,7 +336,7 @@
private void createProcessor() throws MetaMatrixComponentException {
- TransactionContext tc =
transactionService.getOrCreateTransactionContext(workContext.getConnectionID());
+ TransactionContext tc =
transactionService.getOrCreateTransactionContext(workContext.getSessionId());
Assertion.assertTrue(tc.getTransactionType() != TransactionContext.Scope.REQUEST,
"Transaction already associated with request."); //$NON-NLS-1$
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java 2010-04-22
17:22:34 UTC (rev 2072)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -105,7 +105,7 @@
this.sql = sql;
this.vdbInfo = new VDBKey(context.getVdbName(), context.getVdbVersion());
this.pi = pi;
- this.originalSessionId = context.getConnectionID();
+ this.originalSessionId = context.getSessionId();
}
private void setSessionId(String sessionId) {
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java 2010-04-22
17:22:34 UTC (rev 2072)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -290,7 +290,7 @@
// is not authorized in the exception message
handleValidationError(
- DQPPlugin.Util.getString("ERR.018.005.0095", new
Object[]{DQPWorkContext.getWorkContext().getConnectionID(), getActionLabel(actionCode)}),
//$NON-NLS-1$
+ DQPPlugin.Util.getString("ERR.018.005.0095", new
Object[]{DQPWorkContext.getWorkContext().getSessionId(), getActionLabel(actionCode)}),
//$NON-NLS-1$
inaccessibleSymbols);
}
}
Modified:
trunk/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java
===================================================================
---
trunk/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java 2010-04-22
17:22:34 UTC (rev 2072)
+++
trunk/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -43,7 +43,7 @@
public static AtomicRequestMessage example() {
RequestMessage rm = new RequestMessage();
DQPWorkContext workContext = new DQPWorkContext();
- workContext.getSession().setSessionId(2);
+ workContext.getSession().setSessionId(String.valueOf(2));
AtomicRequestMessage message = new AtomicRequestMessage(rm, workContext, 1000);
message.setCommand(TestQueryImpl.helpExample(true));
message.setFetchSize(100);
@@ -64,7 +64,7 @@
assertEquals(example.getProcessingTimestamp(), copy.getProcessingTimestamp());
assertEquals(new RequestID(5000L), copy.getRequestID());
- assertEquals("2", copy.getWorkContext().getConnectionID());
//$NON-NLS-1$
+ assertEquals("2", copy.getWorkContext().getSessionId()); //$NON-NLS-1$
//AtomicRequestMessage-specific stuff
assertEquals("connectorBindingID", copy.getConnectorName());
//$NON-NLS-1$
assertEquals(1000, copy.getAtomicRequestID().getNodeID());
Modified:
trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
===================================================================
---
trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java 2010-04-22
17:22:34 UTC (rev 2072)
+++
trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -87,7 +87,7 @@
workContext.setSession(session);
session.setVDBName(vdb.getName());
session.setVDBVersion(vdb.getVersion());
- session.setSessionId(1);
+ session.setSessionId(String.valueOf(1));
session.setUserName("foo"); //$NON-NLS-1$
session.setVdb(vdb);
workContext.getVDB().addAttchment(QueryMetadataInterface.class, metadata);
Modified:
trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java 2010-04-22
17:22:34 UTC (rev 2072)
+++
trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -44,7 +44,7 @@
DQPWorkContext workContext = new DQPWorkContext();
workContext.getSession().setVDBName("MyVDB"); //$NON-NLS-1$
workContext.getSession().setVDBVersion(1);
- workContext.getSession().setSessionId(1);
+ workContext.getSession().setSessionId(String.valueOf(1));
workContext.getSession().setUserName("foo"); //$NON-NLS-1$
return workContext;
}
@@ -55,17 +55,17 @@
Cache cache =
this.cacheContext.getRequestScopedCache(context.getRequestID(12L).toString());
cache.put("key", "request-value"); //$NON-NLS-1$ //$NON-NLS-2$
- cache = this.cacheContext.getSessionScopedCache(context.getConnectionID());
+ cache = this.cacheContext.getSessionScopedCache(context.getSessionId());
cache.put("key", "session-value"); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("request-value",
this.cacheContext.getRequestScopedCache(context.getRequestID(12L).toString()).get("key"));
//$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("session-value",
this.cacheContext.getSessionScopedCache(context.getConnectionID()).get("key"));
//$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("session-value",
this.cacheContext.getSessionScopedCache(context.getSessionId()).get("key"));
//$NON-NLS-1$ //$NON-NLS-2$
// close the request
this.cacheContext.removeRequestScopedCache(context.getRequestID(12L).toString());
assertNull(this.cacheContext.getRequestScopedCache(context.getRequestID(12L).toString()).get("key"));
//$NON-NLS-1$
- assertEquals("session-value",
this.cacheContext.getSessionScopedCache(context.getConnectionID()).get("key"));
//$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("session-value",
this.cacheContext.getSessionScopedCache(context.getSessionId()).get("key"));
//$NON-NLS-1$ //$NON-NLS-2$
}
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 2010-04-22
17:22:34 UTC (rev 2072)
+++
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -67,7 +67,7 @@
RequestMessage rm = new RequestMessage();
DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(EXAMPLE_BQT,
FakeMetadataFactory.exampleBQTVDB());
- workContext.getSession().setSessionId(1);
+ workContext.getSession().setSessionId(String.valueOf(1));
workContext.getSession().setUserName("foo"); //$NON-NLS-1$
AtomicRequestMessage request = new AtomicRequestMessage(rm, workContext, nodeid);
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 2010-04-22
17:22:34 UTC (rev 2072)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -206,7 +206,7 @@
private ResultsMessage helpExecute(String sql, String userName, int sessionid,
boolean txnAutoWrap) throws Exception {
RequestMessage reqMsg = exampleRequestMessage(sql);
- DQPWorkContext.getWorkContext().getSession().setSessionId(sessionid);
+
DQPWorkContext.getWorkContext().getSession().setSessionId(String.valueOf(sessionid));
DQPWorkContext.getWorkContext().getSession().setUserName(userName);
if (txnAutoWrap) {
reqMsg.setTxnAutoWrapMode(RequestMessage.TXN_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 2010-04-22
17:22:34 UTC (rev 2072)
+++
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -141,7 +141,7 @@
if (workContext == null) {
workContext = new DQPWorkContext();
- workContext.getSession().setSessionId(Long.valueOf(id.getConnectionID()));
+ workContext.getSession().setSessionId(id.getConnectionID());
workContext.getSession().setUserName("foo"); //$NON-NLS-1$
}
RequestWorkItem workItem = new RequestWorkItem(rm, requestMsg, null, null, id,
workContext);
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 2010-04-22
17:22:34 UTC (rev 2072)
+++
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -42,7 +42,7 @@
message.getSession().setVDBName("vdbName"); //$NON-NLS-1$
message.getSession().setVDBVersion(1);
message.getSession().setApplicationName("querybuilder"); //$NON-NLS-1$
- message.getSession().setSessionId(5);
+ message.getSession().setSessionId(String.valueOf(5));
message.getSession().setUserName("userName"); //$NON-NLS-1$
return message;
}
@@ -50,7 +50,7 @@
public void testSerialize() throws Exception {
DQPWorkContext copy = UnitTestUtil.helpSerialize(example());
- assertEquals("5", copy.getConnectionID()); //$NON-NLS-1$
+ assertEquals("5", copy.getSessionId()); //$NON-NLS-1$
assertEquals("userName", copy.getUserName()); //$NON-NLS-1$
assertEquals("vdbName", copy.getVdbName()); //$NON-NLS-1$
assertEquals(1, copy.getVdbVersion());
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 2010-04-22
17:22:34 UTC (rev 2072)
+++
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -244,7 +244,7 @@
}
DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata,
vdb);
- workContext.getSession().setSessionId(conn);
+ workContext.getSession().setSessionId(String.valueOf(conn));
PreparedStatementRequest serverRequest = new
PreparedStatementRequest(prepPlanCache);
Modified: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-04-22
17:22:34 UTC (rev 2072)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -96,7 +96,7 @@
import com.metamatrix.core.util.ObjectConverterUtil;
public class Admin extends TeiidAdmin {
- private static final String CONNECTOR_PREFIX = "connector-";
+ private static final String CONNECTOR_PREFIX = "connector-"; //$NON-NLS-1$
private static final String RAR = ".rar"; //$NON-NLS-1$
private static final ProfileKey DEFAULT_PROFILE_KEY = new
ProfileKey(ProfileKey.DEFAULT);
private static final String XA_DATA_SOURCE_TEMPLATE = "XADataSourceTemplate";
//$NON-NLS-1$
@@ -105,11 +105,11 @@
private static ComponentType VDBTYPE = new ComponentType("teiid",
"vdb");//$NON-NLS-1$ //$NON-NLS-2$
private static ComponentType DQPTYPE = new ComponentType("teiid",
"dqp");//$NON-NLS-1$ //$NON-NLS-2$
private static String DQPNAME = RuntimeEngineDeployer.class.getName();
- private static ExtendedComponentType NOTXTYPE = new
ExtendedComponentType("ConnectionFactory", "NoTx",
"no-tx-connection-factory");//$NON-NLS-1$ //$NON-NLS-2$
- private static ExtendedComponentType TXTYPE = new
ExtendedComponentType("ConnectionFactory", "Tx",
"tx-connection-factory");//$NON-NLS-1$ //$NON-NLS-2$
- private static ExtendedComponentType DS_LOCAL_TX = new
ExtendedComponentType("DataSource", "LocalTx",
"local-tx-datasource");//$NON-NLS-1$ //$NON-NLS-2$
- private static ExtendedComponentType DS_XA_TX = new
ExtendedComponentType("DataSource", "XA",
"xa-datasource");//$NON-NLS-1$ //$NON-NLS-2$
- private static ExtendedComponentType DS_NO_TX = new
ExtendedComponentType("DataSource", "NoTx",
"no-tx-datasource");//$NON-NLS-1$ //$NON-NLS-2$
+ private static ExtendedComponentType NOTXTYPE = new
ExtendedComponentType("ConnectionFactory", "NoTx",
"no-tx-connection-factory");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static ExtendedComponentType TXTYPE = new
ExtendedComponentType("ConnectionFactory", "Tx",
"tx-connection-factory");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static ExtendedComponentType DS_LOCAL_TX = new
ExtendedComponentType("DataSource", "LocalTx",
"local-tx-datasource");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static ExtendedComponentType DS_XA_TX = new
ExtendedComponentType("DataSource", "XA",
"xa-datasource");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static ExtendedComponentType DS_NO_TX = new
ExtendedComponentType("DataSource", "NoTx",
"no-tx-datasource");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
private static ExtendedComponentType[] DS_TYPES = new ExtendedComponentType[] {DS_XA_TX,
DS_LOCAL_TX, DS_NO_TX};
private static ExtendedComponentType[] CF_TYPES = new ExtendedComponentType[] {NOTXTYPE,
TXTYPE};
@@ -204,9 +204,9 @@
private Reader exportJCAConnection(String deployedName, ManagedComponent mc,
ExtendedComponentType type) throws AdminException {
try {
- DeploymentTemplateInfo info = getView().getTemplate("export-template");
+ DeploymentTemplateInfo info = getView().getTemplate("export-template");
//$NON-NLS-1$
if(info == null) {
- throw new
AdminProcessingException(IntegrationPlugin.Util.getString("connector_type_not_found",
"export-template")); //$NON-NLS-1$
+ throw new
AdminProcessingException(IntegrationPlugin.Util.getString("connector_type_not_found",
"export-template")); //$NON-NLS-1$ //$NON-NLS-2$
}
for (ManagedProperty infoProperty:info.getProperties().values()) {
@@ -218,10 +218,10 @@
}
}
- ManagedProperty dsType = info.getProperties().get("dsType");
+ ManagedProperty dsType = info.getProperties().get("dsType"); //$NON-NLS-1$
dsType.setValue(ManagedUtil.wrap(SimpleMetaType.STRING, type.getDsType()));
- File dsXml = File.createTempFile(deployedName, "-ds.xml");
+ File dsXml = File.createTempFile(deployedName, "-ds.xml"); //$NON-NLS-1$
ExportConnectorTypeTemplateInfo.writeTemplate(dsXml, info);
Reader r = new StringReader(ObjectConverterUtil.convertFileToString(dsXml));
dsXml.delete();
@@ -582,20 +582,20 @@
permission.setResourceName(ManagedUtil.getSimpleValue(mo,
"resourceName", String.class));//$NON-NLS-1$
- if (ManagedUtil.getSimpleValue(mo, "allowCreate", Boolean.class)
!= null) {
- permission.setAllowCreate(ManagedUtil.getSimpleValue(mo,
"allowCreate", Boolean.class));
+ if (ManagedUtil.getSimpleValue(mo, "allowCreate", Boolean.class)
!= null) { //$NON-NLS-1$
+ permission.setAllowCreate(ManagedUtil.getSimpleValue(mo,
"allowCreate", Boolean.class)); //$NON-NLS-1$
}
- if (ManagedUtil.getSimpleValue(mo, "allowRead", Boolean.class) !=
null) {
- permission.setAllowRead(ManagedUtil.getSimpleValue(mo,
"allowRead", Boolean.class));
+ if (ManagedUtil.getSimpleValue(mo, "allowRead", Boolean.class) !=
null) { //$NON-NLS-1$
+ permission.setAllowRead(ManagedUtil.getSimpleValue(mo,
"allowRead", Boolean.class)); //$NON-NLS-1$
}
- if (ManagedUtil.getSimpleValue(mo, "allowUpdate", Boolean.class)
!= null) {
- permission.setAllowUpdate(ManagedUtil.getSimpleValue(mo,
"allowUpdate", Boolean.class));
+ if (ManagedUtil.getSimpleValue(mo, "allowUpdate", Boolean.class)
!= null) { //$NON-NLS-1$
+ permission.setAllowUpdate(ManagedUtil.getSimpleValue(mo,
"allowUpdate", Boolean.class)); //$NON-NLS-1$
}
- if (ManagedUtil.getSimpleValue(mo, "allowDelete", Boolean.class)
!= null) {
- permission.setAllowDelete(ManagedUtil.getSimpleValue(mo,
"allowDelete", Boolean.class));
+ if (ManagedUtil.getSimpleValue(mo, "allowDelete", Boolean.class)
!= null) { //$NON-NLS-1$
+ permission.setAllowDelete(ManagedUtil.getSimpleValue(mo,
"allowDelete", Boolean.class)); //$NON-NLS-1$
}
policy.addPermission(permission);
@@ -657,7 +657,7 @@
}
@Override
- public void terminateSession(long sessionId) throws AdminException {
+ public void terminateSession(String sessionId) throws AdminException {
try {
ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
ManagedUtil.executeOperation(mc, "terminateSession",
SimpleValueSupport.wrap(sessionId));//$NON-NLS-1$
@@ -683,7 +683,7 @@
}
@Override
- public Collection<Request> getRequestsForSession(long sessionId) throws
AdminException {
+ public Collection<Request> getRequestsForSession(String sessionId) throws
AdminException {
try {
Collection<Request> requestList = new ArrayList<Request>();
ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
@@ -699,7 +699,7 @@
}
@Override
- public void cancelRequest(long sessionId, long requestId) throws AdminException{
+ public void cancelRequest(String sessionId, long requestId) throws AdminException{
try {
ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
ManagedUtil.executeOperation(mc, "cancelRequest",
SimpleValueSupport.wrap(sessionId), SimpleValueSupport.wrap(requestId));//$NON-NLS-1$
@@ -724,7 +724,7 @@
@Override
public void addConnector(String connectorName, InputStream contents) throws
AdminException{
- if (!connectorName.startsWith(CONNECTOR_PREFIX) || !connectorName.endsWith(RAR))
{//$NON-NLS-1$
+ if (!connectorName.startsWith(CONNECTOR_PREFIX) || !connectorName.endsWith(RAR)) {
throw new
AdminProcessingException(IntegrationPlugin.Util.getString("bad_connector_type_name"));
//$NON-NLS-1$
}
@@ -748,13 +748,13 @@
@Override
public void deleteConnector(String connectorName) throws AdminException {
- if (!connectorName.startsWith(CONNECTOR_PREFIX) || !connectorName.endsWith(RAR))
{//$NON-NLS-1$
+ if (!connectorName.startsWith(CONNECTOR_PREFIX) || !connectorName.endsWith(RAR)) {
throw new
AdminProcessingException(IntegrationPlugin.Util.getString("bad_connector_type_name"));
//$NON-NLS-1$
}
String deployerName = getRarDeployerName(connectorName);
if (deployerName == null) {
- throw new
AdminProcessingException(IntegrationPlugin.Util.getString("connector_not_found",
connectorName));
+ throw new
AdminProcessingException(IntegrationPlugin.Util.getString("connector_not_found",
connectorName)); //$NON-NLS-1$
}
//also need to delete template for the properties
@@ -765,13 +765,13 @@
@Override
public InputStream exportConnector(String connectorName) throws AdminException {
- if (!connectorName.startsWith(CONNECTOR_PREFIX) || !connectorName.endsWith(RAR))
{//$NON-NLS-1$
+ if (!connectorName.startsWith(CONNECTOR_PREFIX) || !connectorName.endsWith(RAR)) {
throw new
AdminProcessingException(IntegrationPlugin.Util.getString("bad_connector_type_name"));
//$NON-NLS-1$
}
String deployerName = getRarDeployerName(connectorName);
if (deployerName == null) {
- throw new
AdminProcessingException(IntegrationPlugin.Util.getString("connector_not_found",
connectorName));
+ throw new
AdminProcessingException(IntegrationPlugin.Util.getString("connector_not_found",
connectorName)); //$NON-NLS-1$
}
return exportDeployment(deployerName);
}
@@ -1109,7 +1109,7 @@
}
}
else {
- roleCollection = new CollectionValueSupport(new
CollectionMetaType("java.util.List", SimpleMetaType.STRING));
+ roleCollection = new CollectionValueSupport(new
CollectionMetaType("java.util.List", SimpleMetaType.STRING)); //$NON-NLS-1$
mappedRoleNames.setValue(roleCollection);
}
@@ -1141,11 +1141,11 @@
public void mergeVDBs(String sourceVDBName, int sourceVDBVersion, String targetVDBName,
int targetVDBVersion) throws AdminException {
try {
ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
- ManagedUtil.executeOperation(mc, "mergeVDBs",
+ ManagedUtil.executeOperation(mc, "mergeVDBs", //$NON-NLS-1$
SimpleValueSupport.wrap(sourceVDBName),
SimpleValueSupport.wrap(sourceVDBVersion),
SimpleValueSupport.wrap(targetVDBName),
- SimpleValueSupport.wrap(targetVDBVersion));//$NON-NLS-1$
+ SimpleValueSupport.wrap(targetVDBVersion));
} catch (Exception e) {
throw new AdminComponentException(e.getMessage(), e);
}
Modified:
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
---
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-04-22
17:22:34 UTC (rev 2072)
+++
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -261,13 +261,13 @@
@Override
@ManagementOperation(description="Terminate a
Session",params={@ManagementParameter(name="terminateeId",description="The
session to be terminated")})
- public void terminateSession(long terminateeId) {
+ public void terminateSession(String terminateeId) {
this.sessionService.terminateSession(terminateeId,
DQPWorkContext.getWorkContext().getSessionId());
}
@Override
@ManagementOperation(description="Cancel a
Request",params={@ManagementParameter(name="sessionId",description="The
session Identifier"),
@ManagementParameter(name="requestId",description="The request
Identifier")})
- public boolean cancelRequest(long sessionId, long requestId) throws AdminException {
+ public boolean cancelRequest(String sessionId, long requestId) throws AdminException
{
try {
return this.dqpCore.cancelRequest(sessionId, requestId);
} catch (MetaMatrixComponentException e) {
Modified: trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2010-04-22
17:22:34 UTC (rev 2072)
+++ trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -32,7 +32,6 @@
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicLong;
import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
@@ -48,8 +47,8 @@
import org.teiid.deployers.VDBRepository;
import org.teiid.deployers.VirtualDatabaseException;
import org.teiid.dqp.internal.process.DQPCore;
-import org.teiid.net.TeiidURL;
import org.teiid.net.ServerConnection;
+import org.teiid.net.TeiidURL;
import org.teiid.runtime.RuntimePlugin;
import org.teiid.security.Credentials;
import org.teiid.security.SecurityHelper;
@@ -81,9 +80,8 @@
private DQPCore dqp;
- private Map<Long, SessionMetadata> sessionCache = new
ConcurrentHashMap<Long, SessionMetadata>();
+ private Map<String, SessionMetadata> sessionCache = new
ConcurrentHashMap<String, SessionMetadata>();
private Timer sessionMonitor = new Timer("SessionMonitor", true);
//$NON-NLS-1$
- private AtomicLong idSequence = new AtomicLong();
private LinkedList<String> securityDomains = new LinkedList<String>();
private LinkedList<String> adminSecurityDomains = new
LinkedList<String>();
@@ -110,7 +108,7 @@
}
@Override
- public void closeSession(long sessionID) throws InvalidSessionException {
+ public void closeSession(String sessionID) throws InvalidSessionException {
LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] {"closeSession",
sessionID}); //$NON-NLS-1$
SessionMetadata info = this.sessionCache.remove(sessionID);
if (info == null) {
@@ -183,9 +181,9 @@
long creationTime = System.currentTimeMillis();
// Return a new session info object
- long id = idSequence.getAndIncrement();
SessionMetadata newSession = new SessionMetadata();
- newSession.setSessionId(id);
+ newSession.setSessionToken(new SessionToken(userName));
+ newSession.setSessionId(newSession.getSessionToken().getSessionID());
newSession.setUserName(userName);
newSession.setCreatedTime(creationTime);
newSession.setApplicationName(applicationName);
@@ -201,8 +199,7 @@
newSession.setLoginContext(loginContext);
newSession.setSecurityContext(securityContext);
newSession.setVdb(vdb);
- newSession.setSessionToken(new SessionToken(id, userName));
- LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] {"Logon
successful for \"", userName, "\" - created SessionID \"",
"" + id, "\"" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$
+ LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] {"Logon
successful for \"", userName, "\" - created SessionID \"",
"" + newSession.getSessionToken().getSessionID(), "\"" });
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
this.sessionCache.put(newSession.getSessionId(), newSession);
return newSession;
}
@@ -220,7 +217,7 @@
}
@Override
- public SessionMetadata getActiveSession(long sessionID) {
+ public SessionMetadata getActiveSession(String sessionID) {
return this.sessionCache.get(sessionID);
}
@@ -245,14 +242,14 @@
}
@Override
- public void pingServer(long sessionID) throws InvalidSessionException {
+ public void pingServer(String sessionID) throws InvalidSessionException {
SessionMetadata info = getSessionInfo(sessionID);
info.setLastPingTime(System.currentTimeMillis());
this.sessionCache.put(sessionID, info);
}
@Override
- public boolean terminateSession(long terminatedSessionID, long adminSessionID) {
+ public boolean terminateSession(String terminatedSessionID, String adminSessionID) {
Object[] params = {adminSessionID, terminatedSessionID};
LogManager.logInfo(LogConstants.CTX_SECURITY, RuntimePlugin.Util.getString(
"SessionServiceImpl.terminateSession", params)); //$NON-NLS-1$
try {
@@ -265,12 +262,12 @@
}
@Override
- public SessionMetadata validateSession(long sessionID) throws InvalidSessionException,
SessionServiceException {
+ public SessionMetadata validateSession(String sessionID) throws InvalidSessionException,
SessionServiceException {
SessionMetadata info = getSessionInfo(sessionID);
return info;
}
- private SessionMetadata getSessionInfo(long sessionID)
+ private SessionMetadata getSessionInfo(String sessionID)
throws InvalidSessionException {
SessionMetadata info = this.sessionCache.get(sessionID);
if (info == null) {
Modified: trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2010-04-22 17:22:34 UTC
(rev 2072)
+++ trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2010-04-22 18:55:02 UTC
(rev 2073)
@@ -83,8 +83,8 @@
}
}
- private long updateDQPContext(SessionMetadata s) {
- long sessionID = s.getSessionId();
+ private String updateDQPContext(SessionMetadata s) {
+ String sessionID = s.getSessionId();
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
workContext.setSession(s);
@@ -93,15 +93,15 @@
public ResultsFuture<?> logoff() throws InvalidSessionException {
this.service.closeSession(DQPWorkContext.getWorkContext().getSessionId());
- DQPWorkContext.getWorkContext().getSession().setSessionId(-1);
+ DQPWorkContext.getWorkContext().getSession().setSessionId(null);
return ResultsFuture.NULL_FUTURE;
}
public ResultsFuture<?> ping() throws
InvalidSessionException,MetaMatrixComponentException {
// ping is double used to alert the aliveness of the client, as well as check the
server instance is
// alive by socket server instance, so that they can be cached.
- long id = DQPWorkContext.getWorkContext().getSessionId();
- if (id != -1) {
+ String id = DQPWorkContext.getWorkContext().getSessionId();
+ if (id != null) {
this.service.pingServer(id);
}
LogManager.logTrace(LogConstants.CTX_SECURITY, "Ping", id); //$NON-NLS-1$
Modified: trunk/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java 2010-04-22
17:22:34 UTC (rev 2072)
+++ trunk/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -139,7 +139,7 @@
} else if (e instanceof AdminProcessingException) {
logProcessingException(e, context);
} else {
- LogManager.logError(context, e,
RuntimePlugin.Util.getString("ServerWorkItem.Received_exception_processing_request",
this.socketClientInstance.getWorkContext().getConnectionID())); //$NON-NLS-1$
+ LogManager.logError(context, e,
RuntimePlugin.Util.getString("ServerWorkItem.Received_exception_processing_request",
this.socketClientInstance.getWorkContext().getSessionId())); //$NON-NLS-1$
}
return new ExceptionHolder(e);
@@ -151,7 +151,7 @@
cause = cause.getCause();
}
StackTraceElement elem = cause.getStackTrace()[0];
- LogManager.logDetail(context, e, "Processing exception for session",
this.socketClientInstance.getWorkContext().getConnectionID()); //$NON-NLS-1$
- LogManager.logWarning(context,
RuntimePlugin.Util.getString("ServerWorkItem.processing_error", e.getMessage(),
this.socketClientInstance.getWorkContext().getConnectionID(), e.getClass().getName(),
elem)); //$NON-NLS-1$
+ LogManager.logDetail(context, e, "Processing exception for session",
this.socketClientInstance.getWorkContext().getSessionId()); //$NON-NLS-1$
+ LogManager.logWarning(context,
RuntimePlugin.Util.getString("ServerWorkItem.processing_error", e.getMessage(),
this.socketClientInstance.getWorkContext().getSessionId(), e.getClass().getName(), elem));
//$NON-NLS-1$
}
}
\ No newline at end of file
Modified: trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java 2010-04-22
17:22:34 UTC (rev 2072)
+++ trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -110,7 +110,7 @@
@Override
public void disconnected() {
- if (workContext.getSessionId() != -1) {
+ if (workContext.getSessionId() != null) {
workContext.runInContext(new Runnable() {
@Override
public void run() {
Modified: trunk/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java 2010-04-22
17:22:34 UTC (rev 2072)
+++ trunk/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -18,7 +18,7 @@
import org.teiid.services.TeiidLoginContext;
import org.teiid.services.SessionServiceImpl;
-
+@SuppressWarnings("nls")
public class TestSessionServiceImpl {
public void validateSession(boolean securityEnabled) throws Exception {
@@ -40,7 +40,7 @@
ssi.setSecurityDomains("somedomain");
try {
- ssi.validateSession(1);
+ ssi.validateSession(String.valueOf(1));
fail("exception expected"); //$NON-NLS-1$
} catch (InvalidSessionException e) {
@@ -48,14 +48,14 @@
SessionMetadata info = ssi.createSession("steve", null, "foo", new
Properties(), false); //$NON-NLS-1$ //$NON-NLS-2$
if (securityEnabled) {
- Mockito.verify(impl).authenticateUser("steve", null, "foo",
domains);
+ Mockito.verify(impl).authenticateUser("steve", null, "foo",
domains);
}
- long id1 = info.getSessionId();
+ String id1 = info.getSessionId();
ssi.validateSession(id1);
assertEquals(1, ssi.getActiveSessionsCount());
- assertEquals(0, ssi.getSessionsLoggedInToVDB("a", 1).size()); //$NON-NLS-1$
//$NON-NLS-2$
+ assertEquals(0, ssi.getSessionsLoggedInToVDB("a", 1).size()); //$NON-NLS-1$
ssi.closeSession(id1);
Modified: trunk/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java 2010-04-22 17:22:34
UTC (rev 2072)
+++ trunk/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java 2010-04-22 18:55:02
UTC (rev 2073)
@@ -50,7 +50,7 @@
SessionMetadata session = new SessionMetadata();
session.setUserName(userName);
session.setApplicationName(applicationName);
- session.setSessionId(1);
+ session.setSessionId(String.valueOf(1));
session.setSessionToken(new SessionToken(1, userName));
Mockito.stub(ssi.createSession(userName, null, applicationName,p,
false)).toReturn(session);
@@ -59,7 +59,7 @@
LogonResult result = impl.logon(p);
assertEquals(userName, result.getUserName());
- assertEquals(1, result.getSessionID());
+ assertEquals(String.valueOf(1), result.getSessionID());
}
Modified:
trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
===================================================================
---
trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2010-04-22
17:22:34 UTC (rev 2072)
+++
trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2010-04-22
18:55:02 UTC (rev 2073)
@@ -178,7 +178,7 @@
t.join();
}
- long sessionId = 0;
+ String sessionId = null;
Collection<Session> sessions = admin.getSessions();
for (Session s:sessions) {
sessionId = s.getSessionId();