Skip to content

Commit

Permalink
Add more logging for when MultiProcessAffinityTest fails
Browse files Browse the repository at this point in the history
  • Loading branch information
nicktindall committed Oct 19, 2021
1 parent 1af6529 commit 0bdef18
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.time.LocalDateTime;
import java.util.concurrent.TimeUnit;

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

public class MultiProcessAffinityTest {

private static final Logger LOGGER = LoggerFactory.getLogger(MultiProcessAffinityTest.class);

@Rule
public TemporaryFolder folder = new TemporaryFolder();
private String originalTmpDir;
Expand Down Expand Up @@ -46,6 +49,8 @@ public void shouldNotAcquireLockOnCoresLockedByOtherProcesses() throws IOExcepti
while (FileLockBasedLockChecker.getInstance().isLockFree(lastCpuId)) {
Thread.sleep(100);
if (System.currentTimeMillis() > endTime) {
LOGGER.info("Timed out waiting for the lock to be acquired: isAlive={}, exitCode={}",
affinityLockerProcess.isAlive(), affinityLockerProcess.isAlive() ? "N/A" : affinityLockerProcess.exitValue());
ProcessRunner.printProcessOutput("AffinityLockerProcess", affinityLockerProcess);
fail("Timed out waiting for the sub-process to acquire the lock");
}
Expand All @@ -70,10 +75,12 @@ public static void main(String[] args) {
String cpuIdToLock = args[0];

try (final AffinityLock affinityLock = AffinityLock.acquireLock(cpuIdToLock)) {
LOGGER.info("Got affinity lock " + affinityLock);
LOGGER.info("Got affinity lock " + affinityLock + " at " + LocalDateTime.now() + ", CPU=" + affinityLock.cpuId());
Thread.sleep(Integer.MAX_VALUE);
LOGGER.error("Woke from sleep? this should never happen");
} catch (InterruptedException e) {
// expected, just end
LOGGER.info("Interrupted at " + LocalDateTime.now() + " lock is released");
}
}
}
Expand Down

0 comments on commit 0bdef18

Please sign in to comment.