Author: shawkins
Date: 2012-09-27 14:42:37 -0400 (Thu, 27 Sep 2012)
New Revision: 4482
Modified:
trunk/admin/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java
trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java
trunk/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
Log:
TEIID-2172 updating the logic to not prematurely terminate
Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java 2012-09-27
10:24:37 UTC (rev 4481)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java 2012-09-27
18:42:37 UTC (rev 4482)
@@ -40,7 +40,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: trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java
===================================================================
--- trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java 2012-09-27
10:24:37 UTC (rev 4481)
+++ trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java 2012-09-27
18:42:37 UTC (rev 4482)
@@ -20,9 +20,6 @@
* 02110-1301 USA.
*/
-/**
- *
- */
package org.teiid.net.socket;
import java.io.IOException;
@@ -338,6 +335,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: trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2012-09-27
10:24:37 UTC (rev 4481)
+++ trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2012-09-27
18:42:37 UTC (rev 4482)
@@ -95,7 +95,7 @@
long currentTime = System.currentTimeMillis();
for (SessionMetadata info : sessionCache.values()) {
try {
- if (!info.isEmbedded() && currentTime - info.getLastPingTime() >
ServerConnection.PING_INTERVAL * 5) {
+ if (!info.isEmbedded() && currentTime - info.getLastPingTime() >
ServerConnection.PING_INTERVAL * 3) {
LogManager.logInfo(LogConstants.CTX_SECURITY,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40007, info.getSessionId()));
closeSession(info.getSessionId());
} else if (sessionExpirationTimeLimit > 0 && currentTime -
info.getCreatedTime() > sessionExpirationTimeLimit) {
@@ -389,7 +389,7 @@
public void run() {
monitorSessions();
}
- }, 0, ServerConnection.PING_INTERVAL * 5);
+ }, ServerConnection.PING_INTERVAL * 3, ServerConnection.PING_INTERVAL * 2);
}
public void stop(){
Modified: trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2012-09-27 10:24:37 UTC
(rev 4481)
+++ trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2012-09-27 18:42:37 UTC
(rev 4482)
@@ -244,6 +244,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: trunk/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2012-09-27
10:24:37 UTC (rev 4481)
+++ trunk/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2012-09-27
18:42:37 UTC (rev 4482)
@@ -32,14 +32,17 @@
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.common.buffer.BufferManagerFactory;
import org.teiid.common.buffer.impl.MemoryStorageManager;
import org.teiid.core.crypto.NullCryptor;
import org.teiid.core.util.ObjectConverterUtil;
+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;
@@ -116,6 +119,7 @@
assertEquals(1, stats.maxSockets);
}
+ @Ignore
@Test public void testLobs() throws Exception {
SocketServerConnection conn = helpEstablishConnection(false);
FakeService fs = conn.getService(FakeService.class);
@@ -222,23 +226,38 @@
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,
assertEquals(1, stats.sockets);
conn.cleanUp();
assertEquals(1, this.service.getActiveSessionsCount());
- helpEstablishConnection(false, config, p);
+ ServerConnection conn2 = helpEstablishConnection(false, config, p);
+ assertEquals(2, this.service.getActiveSessionsCount());
conn.selectServerInstance(false);
assertEquals(2, this.service.getActiveSessionsCount());
assertTrue(conn.isOpen(1000));
stats = listener.getStats();
- assertEquals(7, stats.objectsRead); // ping (pool test), assert identity, ping
(isOpen)
+ assertEquals(8, stats.objectsRead); // (ping (pool test), assert identityx2, ping
(isOpen))x2
assertEquals(2, stats.sockets);
conn.close();
+ conn2.close();
}
@Test public void testEnableCipherSuites() throws Exception {