
com.jeesuite.kafka.utils.NodeNameHolder Maven / Gradle / Ivy
/**
*
*/
package com.jeesuite.kafka.utils;
import java.net.InetAddress;
import java.util.UUID;
import org.apache.commons.lang3.RandomStringUtils;
/**
* @description
* @author vakin
* @date 2016年11月3日
*/
public class NodeNameHolder {
private static String nodeId;
public static String getNodeId() {
if(nodeId != null)return nodeId;
try {
nodeId = InetAddress.getLocalHost().getHostName() + "_" + RandomStringUtils.random(6, true, true).toLowerCase();
} catch (Exception e) {
nodeId = UUID.randomUUID().toString();
}
return nodeId;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy