88import org .slf4j .LoggerFactory ;
99
1010import java .io .IOException ;
11+ import java .time .LocalDateTime ;
1112import java .util .concurrent .TimeUnit ;
1213
1314import static net .openhft .affinity .LockCheck .IS_LINUX ;
1617
1718public 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