/** Usually returns MAC address (48 bits = 6 bytes). */ public static byte[] getMacAddress(final InetAddress addr) { if (SystemUtils.getJavaVersion() < 1.6f) { return null; // getHardwareAddress is not supported } final NetworkInterface ni; try { ni = NetworkInterface.getByInetAddress(addr); } catch (SocketException e) { return null; } if (ni != null) { final byte[] mac; try { mac = ni.getHardwareAddress(); } catch (SocketException e) { return null; } return mac; } return null; }
static { final String counter = System.getProperty("xbird.counter"); if ("cliffc".equals(counter)) { counterType = CounterType.cliffc; } else if ("stripe".equals(counter)) { counterType = CounterType.stripe; } else if ("stripe2".equals(counter)) { counterType = CounterType.stripe2; } else if ("stripe3".equals(counter)) { counterType = CounterType.stripe3; } else if ("atomic".equals(counter)) { counterType = CounterType.atomic; } else { counterType = CounterType.auto; } int nstripe = Integer.parseInt(Settings.get("xbird.util.counter.nstripe", "-1")); if (nstripe == -1) { int procs = SystemUtils.availableProcessors(); nstripe = Math.max(4, procs >> 3); // 4 < x < 8 } NSTRIPE = nstripe; }
public static ICounter createIntCounter(int nstripe) { final int procs = SystemUtils.availableProcessors(); switch (counterType) { case cliffc: return new HighScalableIntCounter(); case stripe: return new StripeAtomicIntCounter(nstripe); case stripe2: return new StripeAtomicIntCounter2(nstripe); case stripe3: return new StripeAtomicIntCounter3(nstripe); case atomic: return new AtomicIntCounter(); case auto: default: if (procs > 64) { return new HighScalableIntCounter(); } else if (procs > 32) { return new StripeAtomicIntCounter(nstripe); } else { return new AtomicIntCounter(); } } }