Author: jolee
Date: 2012-10-19 14:42:47 -0400 (Fri, 19 Oct 2012)
New Revision: 4519
Modified:
branches/7.7.x/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
branches/7.7.x/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java
branches/7.7.x/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
branches/7.7.x/runtime/src/main/java/org/teiid/transport/LogonImpl.java
branches/7.7.x/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
Log:
TEIID-2172: Load balancing configuration can result in premature session
termination/updating the logic to not prematurely terminiate
Modified:
branches/7.7.x/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
===================================================================
---
branches/7.7.x/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java 2012-10-05
14:12:08 UTC (rev 4518)
+++
branches/7.7.x/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java 2012-10-19
18:42:47 UTC (rev 4519)
@@ -44,7 +44,7 @@
private static final long serialVersionUID = 918638989081830034L;
private String applicationName;
- private long lastPingTime = System.currentTimeMillis();
+ private volatile long lastPingTime = System.currentTimeMillis();
private long createdTime;
private String ipAddress;
private String clientHostName;
Modified:
branches/7.7.x/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java
===================================================================
---
branches/7.7.x/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java 2012-10-05
14:12:08 UTC (rev 4518)
+++
branches/7.7.x/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java 2012-10-19
18:42:47 UTC (rev 4519)
@@ -20,9 +20,6 @@
* 02110-1301 USA.
*/
-/**
- *
- */
package org.teiid.net.socket;
import java.io.IOException;
@@ -339,6 +336,15 @@
}
public void cleanUp() {
+ if (this.serverInstance != null && this.logonResult != null &&
"8.2".compareTo(this.serverInstance.getServerVersion()) <= 0) {
//$NON-NLS-1$
+ ILogon newLogon = this.serverInstance.getService(ILogon.class);
+ try {
+ newLogon.assertIdentity(null);
+ } catch (InvalidSessionException e) {
+ } catch (TeiidComponentException e) {
+ } catch (CommunicationException e) {
+ }
+ }
closeServerInstance();
}
Modified: branches/7.7.x/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
===================================================================
---
branches/7.7.x/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2012-10-05
14:12:08 UTC (rev 4518)
+++
branches/7.7.x/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2012-10-19
18:42:47 UTC (rev 4519)
@@ -401,7 +401,7 @@
public void run() {
monitorSessions();
}
- }, 0, ServerConnection.PING_INTERVAL * 5);
+ }, ServerConnection.PING_INTERVAL * 3, ServerConnection.PING_INTERVAL * 2);
}
public void stop(){
Modified: branches/7.7.x/runtime/src/main/java/org/teiid/transport/LogonImpl.java
===================================================================
--- branches/7.7.x/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2012-10-05
14:12:08 UTC (rev 4518)
+++ branches/7.7.x/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2012-10-19
18:42:47 UTC (rev 4519)
@@ -84,8 +84,8 @@
private LogonResult logon(Properties connProps, byte[] krb5ServiceTicket) throws
LogonException {
- DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- String oldSessionId = workContext.getSessionId();
+ //DQPWorkContext workContext = DQPWorkContext.getWorkContext();
+ //String oldSessionId = workContext.getSessionId();
String applicationName = connProps.getProperty(TeiidURL.CONNECTION.APP_NAME);
// user may be null if using trustedToken to log on
String user = connProps.getProperty(TeiidURL.CONNECTION.USER_NAME,
CoreConstants.DEFAULT_ANON_USERNAME);
@@ -103,12 +103,10 @@
if (DQPWorkContext.getWorkContext().getClientAddress() == null) {
sessionInfo.setEmbedded(true);
}
- if (oldSessionId != null) {
- try {
- this.service.closeSession(oldSessionId);
- } catch (InvalidSessionException e) {
- }
- }
+ //if (oldSessionId != null) {
+ //TODO: we should be smarter about disassociating the old sessions from the
client. we'll just rely on
+ //ping based clean up
+ //}
LogonResult result = new LogonResult(sessionInfo.getSessionToken(),
sessionInfo.getVDBName(), sessionInfo.getVDBVersion(), clusterName);
if (krb5ServiceTicket != null) {
result.addProperty(ILogon.KRB5TOKEN, krb5ServiceTicket);
@@ -248,6 +246,11 @@
@Override
public void assertIdentity(SessionToken checkSession) throws InvalidSessionException,
TeiidComponentException {
+ if (checkSession == null) {
+ //disassociate
+ this.updateDQPContext(new SessionMetadata());
+ return;
+ }
SessionMetadata sessionInfo = null;
try {
sessionInfo = this.service.validateSession(checkSession.getSessionID());
Modified: branches/7.7.x/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
===================================================================
---
branches/7.7.x/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2012-10-05
14:12:08 UTC (rev 4518)
+++
branches/7.7.x/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2012-10-19
18:42:47 UTC (rev 4519)
@@ -33,6 +33,7 @@
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.teiid.client.security.ILogon;
import org.teiid.client.security.InvalidSessionException;
@@ -47,8 +48,10 @@
import org.teiid.core.crypto.NullCryptor;
import org.teiid.core.util.ObjectConverterUtil;
import org.teiid.dqp.service.SessionService;
+import org.teiid.dqp.service.SessionServiceException;
import org.teiid.net.CommunicationException;
import org.teiid.net.ConnectionException;
+import org.teiid.net.ServerConnection;
import org.teiid.net.TeiidURL;
import org.teiid.net.socket.SocketServerConnection;
import org.teiid.net.socket.SocketServerConnectionFactory;
@@ -123,6 +126,7 @@
assertEquals(1, stats.maxSockets);
}
+ @Ignore
@Test public void testLobs() throws Exception {
SocketServerConnection conn = helpEstablishConnection(false);
FakeService fs = conn.getService(FakeService.class);
@@ -241,9 +245,22 @@
helpEstablishConnection(true, config, p);
}
- @Test public void testSelectNewInstance() throws Exception {
+ @Test public void testSelectNewInstanceWithoutPooling() throws Exception {
+ Properties p = new Properties();
+ p.setProperty("org.teiid.sockets.maxCachedInstances", "0");
+ helpTestNewInstance(p);
+ }
+
+ @Test public void testSelectNewInstanceWithPooling() throws Exception {
+ Properties p = new Properties();
+ p.setProperty("org.teiid.sockets.maxCachedInstances", "16");
+ helpTestNewInstance(p);
+ }
+
+ private void helpTestNewInstance(Properties p)
+ throws CommunicationException, ConnectionException,
+ SessionServiceException {
SSLConfiguration config = new SSLConfiguration();
- Properties p = new Properties();
SocketServerConnection conn = helpEstablishConnection(false, config, p);
SocketListenerStats stats = listener.getStats();
assertEquals(2, stats.objectsRead); // handshake response, logon,