/* Log the number of fds used before and after a test is run. Verifies
* we are freeing resources correctly. Unfortunately this only works
* on unix systems (the only place sun has implemented as part of the
* mgmt bean api).
*/
UnixOperatingSystemMXBean unixos =
(UnixOperatingSystemMXBean) osMbean;
long initialFdCount = unixos.getOpenFileDescriptorCount();
VerifyClientCleanup threads[] = new VerifyClientCleanup[threadCount];
for (int i = 0; i < threads.length; i++) {
threads[i] = new VerifyClientCleanup("VCC" + i, clientCount);
threads[i].start();
}
for (int i = 0; i < threads.length; i++) {
threads[i].join(CONNECTION_TIMEOUT);
Assert.assertTrue(threads[i].current == threads[i].count);
}
// if this Assert.fails it means we are not cleaning up after the closed
// sessions.
long currentCount = unixos.getOpenFileDescriptorCount();
final String logmsg = "open fds after test ({}) are not significantly higher than before ({})";
if (currentCount > initialFdCount + 10) {
// consider as error
LOG.error(logmsg,Long.valueOf(currentCount),Long.valueOf(initialFdCount));