Skip to content

Commit f175ad1

Browse files
committed
Revert "Merge pull request #1534 from shapeblue/niotest-fix"
This reverts commit 9f970f2, reversing changes made to 6d0c92b. This was reverted because it seemed to be related to an issue when doing a DeployDC, causing an `addHost` error.
1 parent 4e1f9cd commit f175ad1

File tree

3 files changed

+11
-18
lines changed

3 files changed

+11
-18
lines changed

utils/src/main/java/com/cloud/utils/nio/Link.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,8 @@ public static boolean doHandshake(final SocketChannel socketChannel, final SSLEn
596596
while (handshakeStatus != SSLEngineResult.HandshakeStatus.FINISHED
597597
&& handshakeStatus != SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING) {
598598
final long timeTaken = System.currentTimeMillis() - startTimeMills;
599-
if (timeTaken > 15000L) {
600-
s_logger.warn("SSL Handshake has taken more than 15s to connect to: " + socketChannel.getRemoteAddress() +
599+
if (timeTaken > 60000L) {
600+
s_logger.warn("SSL Handshake has taken more than 60s to connect to: " + socketChannel.getRemoteAddress() +
601601
". Please investigate this connection.");
602602
return false;
603603
}

utils/src/main/java/com/cloud/utils/nio/NioConnection.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,6 @@ public Boolean call() throws NioConnectionException {
171171
} catch (final IOException e) {
172172
s_logger.error("Agent will die due to this IOException!", e);
173173
throw new NioConnectionException(e.getMessage(), e);
174-
} finally {
175-
_selector.wakeup();
176174
}
177175
}
178176
_isStartup = false;

utils/src/test/java/com/cloud/utils/testcase/NioTest.java

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,17 @@ public class NioTest {
6161
private static final Logger LOGGER = Logger.getLogger(NioTest.class);
6262

6363
// Test should fail in due time instead of looping forever
64-
private static final int TESTTIMEOUT = 60000;
64+
private static final int TESTTIMEOUT = 300000;
6565

66-
final private int totalTestCount = 4;
66+
final private int totalTestCount = 5;
6767
private int completedTestCount = 0;
6868

6969
private NioServer server;
7070
private List<NioClient> clients = new ArrayList<>();
7171
private List<NioClient> maliciousClients = new ArrayList<>();
7272

7373
private ExecutorService clientExecutor = Executors.newFixedThreadPool(totalTestCount, new NamedThreadFactory("NioClientHandler"));;
74-
private ExecutorService maliciousExecutor = Executors.newFixedThreadPool(totalTestCount, new NamedThreadFactory("MaliciousNioClientHandler"));;
74+
private ExecutorService maliciousExecutor = Executors.newFixedThreadPool(5*totalTestCount, new NamedThreadFactory("MaliciousNioClientHandler"));;
7575

7676
private Random randomGenerator = new Random();
7777
private byte[] testBytes;
@@ -105,18 +105,12 @@ public void setUp() {
105105
Assert.fail(e.getMessage());
106106
}
107107

108-
/**
109-
* The malicious client(s) tries to block NioServer's main IO loop
110-
* thread until SSL handshake timeout value (from Link class, 15s) after
111-
* which the valid NioClient(s) get the opportunity to make connection(s)
112-
*/
113-
for (int i = 0; i < totalTestCount; i++) {
114-
final NioClient maliciousClient = new NioMaliciousClient("NioMaliciousTestClient-" + i, "127.0.0.1", server.getPort(), 1, new NioMaliciousTestClient());
115-
maliciousClients.add(maliciousClient);
116-
maliciousExecutor.submit(new ThreadedNioClient(maliciousClient));
117-
}
118-
119108
for (int i = 0; i < totalTestCount; i++) {
109+
for (int j = 0; j < 4; j++) {
110+
final NioClient maliciousClient = new NioMaliciousClient("NioMaliciousTestClient-" + i, "127.0.0.1", server.getPort(), 1, new NioMaliciousTestClient());
111+
maliciousClients.add(maliciousClient);
112+
maliciousExecutor.submit(new ThreadedNioClient(maliciousClient));
113+
}
120114
final NioClient client = new NioClient("NioTestClient-" + i, "127.0.0.1", server.getPort(), 1, new NioTestClient());
121115
clients.add(client);
122116
clientExecutor.submit(new ThreadedNioClient(client));
@@ -292,6 +286,7 @@ public void doTask(final Task task) {
292286
LOGGER.info("Server: Received OTHER task");
293287
}
294288
}
289+
295290
}
296291
}
297292
}

0 commit comments

Comments
 (0)