From: <pn...@hy...> - 2010-02-26 18:12:24
|
Author: pnguyen Date: 2010-02-26 10:12:06 -0800 (Fri, 26 Feb 2010) New Revision: 14326 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14326 Modified: trunk/src/org/hyperic/hq/bizapp/agent/client/SecureAgentConnection.java Log: [HHQ-3694] Allow the post handshake timeout to be configurable via a system property. Modified: trunk/src/org/hyperic/hq/bizapp/agent/client/SecureAgentConnection.java =================================================================== --- trunk/src/org/hyperic/hq/bizapp/agent/client/SecureAgentConnection.java 2010-02-26 09:34:39 UTC (rev 14325) +++ trunk/src/org/hyperic/hq/bizapp/agent/client/SecureAgentConnection.java 2010-02-26 18:12:06 UTC (rev 14326) @@ -6,7 +6,7 @@ * normal use of the program, and does *not* fall under the heading of * "derived work". * - * Copyright (C) [2004, 2005, 2006], Hyperic, Inc. + * Copyright (C) [2004-2010], Hyperic, Inc. * This file is part of HQ. * * HQ is free software; you can redistribute it and/or modify @@ -54,7 +54,9 @@ extends AgentConnection { private static final String PROP_READ_TIMEOUT = "agent.readTimeOut"; + private static final String PROP_POST_HANDSHAKE_TIMEOUT = "agent.postHandshakeTimeOut"; private static final int READ_TIMEOUT = 60000; + private static final int POST_HANDSHAKE_TIMEOUT = 60000; private String agentAddress; private int agentPort; @@ -78,7 +80,9 @@ private SSLSocket getSSLSocket(SSLSocketFactory factory, String host, - int port, int timeout) + int port, + int readTimeout, + int postHandshakeTimeout) throws IOException { SSLSocket socket; @@ -89,19 +93,18 @@ //XXX we could check if the jre is at the required patch level if (!JDK.IS_IBM) { socket = (SSLSocket)factory.createSocket(); - socket.connect(new InetSocketAddress(host, port), timeout); + socket.connect(new InetSocketAddress(host, port), readTimeout); } else { socket = (SSLSocket)factory.createSocket(host, port); } // Set the socket timeout during the initial handshake to detect - // connection issues with the agent. The timeout is reset to 0 - // (unlimited) post handshake, preserving the behavior for 3.1 and - // prior. - socket.setSoTimeout(timeout); + // connection issues with the agent. + socket.setSoTimeout(readTimeout); socket.startHandshake(); - socket.setSoTimeout(0); + // [HHQ-3694] The timeout is set to a post handshake value. + socket.setSoTimeout(postHandshakeTimeout); return socket; } @@ -138,17 +141,28 @@ try { // Check for configured agent read timeout from System properties - int timeout; - String readTimeout = System.getProperty(PROP_READ_TIMEOUT); + int readTimeout; try { - timeout = Integer.parseInt(readTimeout); + readTimeout = + Integer.parseInt(System.getProperty(PROP_READ_TIMEOUT)); } catch (NumberFormatException e) { - timeout = READ_TIMEOUT; + readTimeout = READ_TIMEOUT; } + + // Check for configured agent post handshake timeout + // from System properties + int postHandshakeTimeout; + try { + postHandshakeTimeout = + Integer.parseInt(System.getProperty(PROP_POST_HANDSHAKE_TIMEOUT)); + } catch (NumberFormatException e) { + postHandshakeTimeout = POST_HANDSHAKE_TIMEOUT; + } factory = context.getSocketFactory(); sock = getSSLSocket(factory, this.agentAddress, - this.agentPort, timeout); + this.agentPort, readTimeout, + postHandshakeTimeout); } catch(IOException exc){ throw new AgentConnectionException("Unable to connect to " + this.agentAddress + ":" + |