Skip to content

Commit 4f775df

Browse files
committed
Improve logging of errors
1 parent 819aaa8 commit 4f775df

5 files changed

Lines changed: 38 additions & 8 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
<groupId>vanilla.java</groupId>
2424
<artifactId>affinity</artifactId>
25-
<version>1.2.1</version>
25+
<version>1.2.2</version>
2626
<packaging>jar</packaging>
2727

2828
<licenses>

src/main/java/vanilla/java/affinity/impl/NativeAffinity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public enum NativeAffinity implements IAffinity {
3636
System.loadLibrary("affinity");
3737
loaded = true;
3838
} catch (UnsatisfiedLinkError ule) {
39-
if (LOGGER.isLoggable(Level.FINE))
40-
LOGGER.fine("Unable to find libaffinity in " + System.getProperty("java.library.path") + " " + ule);
39+
if (LOGGER.isLoggable(Level.INFO))
40+
LOGGER.info("Unable to find libaffinity in " + System.getProperty("java.library.path") + " " + ule);
4141
loaded = false;
4242
}
4343
LOADED = loaded;

src/main/java/vanilla/java/affinity/impl/PosixJNAAffinity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public int sched_getaffinity(final int pid,
6767
INSTANCE.getAffinity();
6868
loaded = true;
6969
} catch (UnsatisfiedLinkError e) {
70-
LOGGER.log(Level.WARNING, "Unable to load jna library", e);
70+
LOGGER.log(Level.WARNING, "Unable to load jna library " + e);
7171
}
7272
LOADED = loaded;
7373
}

src/main/java/vanilla/java/clock/ClockSupport.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
* @since 29.12.11, 19:02
2828
*/
2929
public final class ClockSupport {
30-
private static final IClock CLOCK_IMPL;
30+
public static final IClock INSTANCE;
3131

3232
static {
3333
if (JNIClock.LOADED) {
34-
CLOCK_IMPL = JNIClock.INSTANCE;
34+
INSTANCE = JNIClock.INSTANCE;
3535
} else {
36-
CLOCK_IMPL = SystemClock.INSTANCE;
36+
INSTANCE = SystemClock.INSTANCE;
3737
}
3838
}
3939

@@ -42,6 +42,6 @@ public final class ClockSupport {
4242
* @see vanilla.java.clock.IClock#nanoTime()
4343
*/
4444
public static long nanoTime() {
45-
return CLOCK_IMPL.nanoTime();
45+
return INSTANCE.nanoTime();
4646
}
4747
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package vanilla.java.affinity;
2+
3+
/**
4+
* @author peter.lawrey
5+
*/
6+
public class AffinitySupportMain {
7+
public static void main(String... args) {
8+
AffinityLock al = AffinityLock.acquireLock();
9+
try {
10+
new Thread(new SleepRunnable(), "reader").start();
11+
new Thread(new SleepRunnable(), "writer").start();
12+
new Thread(new SleepRunnable(), "engine").start();
13+
} finally {
14+
al.release();
15+
}
16+
System.out.println("\nThe assignment of CPUs is\n" + AffinityLock.dumpLocks());
17+
}
18+
19+
private static class SleepRunnable implements Runnable {
20+
public void run() {
21+
AffinityLock al = AffinityLock.acquireLock();
22+
try {
23+
Thread.sleep(1000);
24+
} catch (InterruptedException e) {
25+
} finally {
26+
al.release();
27+
}
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)