Browse Source

打印下worerId up2

master
jianjun 4 years ago
parent
commit
e318a525b3
  1. 10
      epmet-user/epmet-user-server/src/main/java/com/epmet/MySequence.java

10
epmet-user/epmet-user-server/src/main/java/com/epmet/MySequence.java

@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.core.toolkit.Assert;
import com.baomidou.mybatisplus.core.toolkit.StringPool; import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.SystemClock; import com.baomidou.mybatisplus.core.toolkit.SystemClock;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.logging.Log; import org.apache.ibatis.logging.Log;
import org.apache.ibatis.logging.LogFactory; import org.apache.ibatis.logging.LogFactory;
@ -36,6 +37,7 @@ import java.util.concurrent.ThreadLocalRandom;
* @author hubin * @author hubin
* @since 2016-08-18 * @since 2016-08-18
*/ */
@Slf4j
public class MySequence { public class MySequence {
private static final Log logger = LogFactory.getLog(MySequence.class); private static final Log logger = LogFactory.getLog(MySequence.class);
@ -80,7 +82,7 @@ public class MySequence {
public MySequence() { public MySequence() {
this.datacenterId = getDatacenterId(maxDatacenterId); this.datacenterId = getDatacenterId(maxDatacenterId);
this.workerId = getMaxWorkerId(datacenterId, maxWorkerId); this.workerId = getMaxWorkerId(datacenterId, maxWorkerId);
logger.warn("MySequence datacenterId:"+this.datacenterId+";workerId:"+this.workerId); log.info("MySequence datacenterId:"+this.datacenterId+";workerId:"+this.workerId);
} }
/** /**
@ -105,7 +107,7 @@ public class MySequence {
StringBuilder mpid = new StringBuilder(); StringBuilder mpid = new StringBuilder();
mpid.append(datacenterId); mpid.append(datacenterId);
String name = ManagementFactory.getRuntimeMXBean().getName(); String name = ManagementFactory.getRuntimeMXBean().getName();
logger.warn("MySequence getMaxWorkerId name:"+name); log.info("MySequence getMaxWorkerId name:"+name);
if (StringUtils.isNotBlank(name)) { if (StringUtils.isNotBlank(name)) {
/* /*
* GET jvmPid * GET jvmPid
@ -126,10 +128,10 @@ public class MySequence {
try { try {
InetAddress ip = InetAddress.getLocalHost(); InetAddress ip = InetAddress.getLocalHost();
NetworkInterface network = NetworkInterface.getByInetAddress(ip); NetworkInterface network = NetworkInterface.getByInetAddress(ip);
logger.warn("MySequence ip:"+JSON.toJSONString(ip)+";network: "+JSON.toJSONString(network)); log.info("MySequence ip:"+JSON.toJSONString(ip)+";network: "+JSON.toJSONString(network));
if (network == null) { if (network == null) {
id = 1L; id = 1L;
logger.warn("MySequen cenetwork ==null "); log.info("MySequen cenetwork ==null ");
} else { } else {
byte[] mac = network.getHardwareAddress(); byte[] mac = network.getHardwareAddress();
if (null != mac) { if (null != mac) {

Loading…
Cancel
Save