Skip to content

Commit 0bdef18

Browse files
committed
Add more logging for when MultiProcessAffinityTest fails
1 parent 1af6529 commit 0bdef18

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

affinity/src/test/java/net/openhft/affinity/MultiProcessAffinityTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.slf4j.LoggerFactory;
99

1010
import java.io.IOException;
11+
import java.time.LocalDateTime;
1112
import java.util.concurrent.TimeUnit;
1213

1314
import static net.openhft.affinity.LockCheck.IS_LINUX;
@@ -16,6 +17,8 @@
1617

1718
public class MultiProcessAffinityTest {
1819

20+
private static final Logger LOGGER = LoggerFactory.getLogger(MultiProcessAffinityTest.class);
21+
1922
@Rule
2023
public TemporaryFolder folder = new TemporaryFolder();
2124
private String originalTmpDir;
@@ -46,6 +49,8 @@ public void shouldNotAcquireLockOnCoresLockedByOtherProcesses() throws IOExcepti
4649
while (FileLockBasedLockChecker.getInstance().isLockFree(lastCpuId)) {
4750
Thread.sleep(100);
4851
if (System.currentTimeMillis() > endTime) {
52+
LOGGER.info("Timed out waiting for the lock to be acquired: isAlive={}, exitCode={}",
53+
affinityLockerProcess.isAlive(), affinityLockerProcess.isAlive() ? "N/A" : affinityLockerProcess.exitValue());
4954
ProcessRunner.printProcessOutput("AffinityLockerProcess", affinityLockerProcess);
5055
fail("Timed out waiting for the sub-process to acquire the lock");
5156
}
@@ -70,10 +75,12 @@ public static void main(String[] args) {
7075
String cpuIdToLock = args[0];
7176

7277
try (final AffinityLock affinityLock = AffinityLock.acquireLock(cpuIdToLock)) {
73-
LOGGER.info("Got affinity lock " + affinityLock);
78+
LOGGER.info("Got affinity lock " + affinityLock + " at " + LocalDateTime.now() + ", CPU=" + affinityLock.cpuId());
7479
Thread.sleep(Integer.MAX_VALUE);
80+
LOGGER.error("Woke from sleep? this should never happen");
7581
} catch (InterruptedException e) {
7682
// expected, just end
83+
LOGGER.info("Interrupted at " + LocalDateTime.now() + " lock is released");
7784
}
7885
}
7986
}

0 commit comments

Comments
 (0)