in src/main/java/org/apache/sling/jobs/impl/Utils.java [52:88]
private static String generateUniqueNamespace() {
String macAddress = null;
// get the MAC address of the primary interface, failing that use a fake.
try {
for ( Enumeration<NetworkInterface> netInterfaceE = NetworkInterface.getNetworkInterfaces(); netInterfaceE.hasMoreElements();) {
NetworkInterface netInterface = netInterfaceE.nextElement();
byte[] hw = netInterface.getHardwareAddress();
if ( !netInterface.isLoopback() && !netInterface.isVirtual() && hw != null) {
macAddress = tohex(hw);
LOGGER.info("Job IDs seeded with MAC Address from interface {} ", netInterface);
break;
}
}
if ( macAddress == null) {
LOGGER.info("No MAC address available, seeding JobID from startup time.");
macAddress = "fake-" + System.currentTimeMillis();
}
} catch (SocketException e) {
LOGGER.warn("Unable to get MAC address, defaulting to fake ", e);
}
long processID;
try {
// most JVMs.
processID = Long.parseLong(java.lang.management.ManagementFactory.getRuntimeMXBean().getName().split("@")[0]);
} catch (Exception e) {
try {
// most Linux kernels.
processID = Long.parseLong(new File("/proc/self").getCanonicalFile().getName());
} catch (Exception e1) {
LOGGER.warn("Unable to get ProcessID by address, defaulting to fake ", e);
processID = System.currentTimeMillis(); // this will be way beyond any process ID.
}
}
String baseId = macAddress + "/" + processID+ "/";
LOGGER.info("Job IDS base is {} ", baseId);
return baseId;
}