mirror of https://github.com/apache/cloudstack.git
agent ssl handshake timeout
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
parent
0b8ebb08d6
commit
3ebc6c3d1e
|
|
@ -159,7 +159,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
|
|||
_shell = shell;
|
||||
_link = null;
|
||||
|
||||
_connection = new NioClient("Agent", _shell.getNextHost(), _shell.getPort(), _shell.getWorkers(), this);
|
||||
_connection = new NioClient("Agent", _shell.getNextHost(), _shell.getPort(), _shell.getWorkers(), _shell.getSslHandshakeTimeout(), this);
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(_shutdownThread);
|
||||
|
||||
|
|
@ -195,7 +195,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
|
|||
}
|
||||
|
||||
final String host = _shell.getNextHost();
|
||||
_connection = new NioClient("Agent", host, _shell.getPort(), _shell.getWorkers(), this);
|
||||
_connection = new NioClient("Agent", host, _shell.getPort(), _shell.getWorkers(), _shell.getSslHandshakeTimeout(), this);
|
||||
|
||||
// ((NioClient)_connection).setBindAddress(_shell.getPrivateIp());
|
||||
|
||||
|
|
@ -291,7 +291,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
|
|||
while (!_connection.isStartup()) {
|
||||
final String host = _shell.getNextHost();
|
||||
_shell.getBackoffAlgorithm().waitBeforeRetry();
|
||||
_connection = new NioClient("Agent", host, _shell.getPort(), _shell.getWorkers(), this);
|
||||
_connection = new NioClient("Agent", host, _shell.getPort(), _shell.getWorkers(), _shell.getSslHandshakeTimeout(), this);
|
||||
s_logger.info("Connecting to host:" + host);
|
||||
try {
|
||||
_connection.start();
|
||||
|
|
@ -552,7 +552,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
|
|||
|
||||
do {
|
||||
final String host = _shell.getNextHost();
|
||||
_connection = new NioClient("Agent", host, _shell.getPort(), _shell.getWorkers(), this);
|
||||
_connection = new NioClient("Agent", host, _shell.getPort(), _shell.getWorkers(), _shell.getSslHandshakeTimeout(), this);
|
||||
s_logger.info("Reconnecting to host:" + host);
|
||||
try {
|
||||
_connection.start();
|
||||
|
|
|
|||
|
|
@ -459,6 +459,11 @@ public class AgentShell implements IAgentShell, Daemon {
|
|||
agent.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getSslHandshakeTimeout() {
|
||||
return AgentPropertiesFileHandler.getPropertyValue(AgentProperties.SSL_HANDSHAKE_TIMEOUT);
|
||||
}
|
||||
|
||||
public synchronized int getNextAgentId() {
|
||||
return _nextAgentId++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,4 +70,6 @@ public interface IAgentShell {
|
|||
String getConnectedHost();
|
||||
|
||||
void launchNewAgent(ServerResource resource) throws ConfigurationException;
|
||||
|
||||
Integer getSslHandshakeTimeout();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -762,6 +762,13 @@ public class AgentProperties{
|
|||
*/
|
||||
public static final Property<String> HOST_TAGS = new Property<>("host.tags", null, String.class);
|
||||
|
||||
/**
|
||||
* Timeout for SSL handshake in seconds
|
||||
* Data type: Integer.<br>
|
||||
* Default value: <code>null</code>
|
||||
*/
|
||||
public static final Property<Integer> SSL_HANDSHAKE_TIMEOUT = new Property<>("ssl.handshake.timeout", null, Integer.class);
|
||||
|
||||
public static class Property <T>{
|
||||
private String name;
|
||||
private T defaultValue;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public class NioClient extends NioConnection {
|
|||
protected String _host;
|
||||
protected SocketChannel _clientConnection;
|
||||
|
||||
public NioClient(final String name, final String host, final int port, final int workers, final HandlerFactory factory) {
|
||||
public NioClient(final String name, final String host, final int port, final int workers, final Integer sslHandshakeTimeout, final HandlerFactory factory) {
|
||||
super(name, port, workers, 1, 2, factory);
|
||||
_host = host;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ public class NioTest {
|
|||
maliciousClients.add(maliciousClient);
|
||||
maliciousExecutor.submit(new ThreadedNioClient(maliciousClient));
|
||||
|
||||
final NioClient client = new NioClient("NioTestClient-" + i, "127.0.0.1", server.getPort(), 1, new NioTestClient());
|
||||
final NioClient client = new NioClient("NioTestClient-" + i, "127.0.0.1", server.getPort(), 1, null, new NioTestClient());
|
||||
clients.add(client);
|
||||
clientExecutor.submit(new ThreadedNioClient(client));
|
||||
}
|
||||
|
|
@ -179,7 +179,7 @@ public class NioTest {
|
|||
public class NioMaliciousClient extends NioClient {
|
||||
|
||||
public NioMaliciousClient(String name, String host, int port, int workers, HandlerFactory factory) {
|
||||
super(name, host, port, workers, factory);
|
||||
super(name, host, port, workers, null, factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue