33 String macAddressFromFile = LicenseFile.MacAddress.getMacAddress();
34 if (!Strings.isNullOrEmpty(macAddressFromFile)) {
35 LOG.trace(
"Mac address fetched from file: " + macAddressFromFile);
36 return macAddressFromFile;
39 InetAddress ip = InetAddress.getLocalHost();
40 LOG.trace(
"Generating new mac address ... ip: " + ip);
41 NetworkInterface network = NetworkInterface.getByInetAddress(ip);
42 if (network != null) {
43 byte[] mac = network.getHardwareAddress();
44 if (mac != null && mac.length > 0) {
48 LOG.error(
"Failed to obtain network interface.");
51 for (NetworkInterface networkInterface : Collections.list(NetworkInterface.getNetworkInterfaces())) {
52 byte[] mac = networkInterface.getHardwareAddress();
54 if (mac != null && mac.length > 0) {
58 }
catch (Exception e) {
59 LOG.error(e.getMessage(), e);
62 String uuid = UUID.randomUUID().toString();
63 LOG.debug(
"Generated fallback UUID instead of mac address:" + uuid);
static String macAsString(byte[] mac)
Definition: MacAddressProvider.java:67
static final Logger LOG
Definition: MacAddressProvider.java:19