|
@@ -13,6 +13,7 @@ import com.persagy.configuration.MyBatisPlusConfig;
|
|
import com.persagy.entity.RwdObjectWd;
|
|
import com.persagy.entity.RwdObjectWd;
|
|
import com.persagy.mapper.RwdObjectWdMapper;
|
|
import com.persagy.mapper.RwdObjectWdMapper;
|
|
import com.persagy.utils.CacheUtil;
|
|
import com.persagy.utils.CacheUtil;
|
|
|
|
+import com.persagy.utils.DBUtil;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -42,6 +43,8 @@ public class BinlogClientRunner implements CommandLineRunner {
|
|
@Autowired
|
|
@Autowired
|
|
private RwdObjectWdMapper rwdObjectWdMapper;
|
|
private RwdObjectWdMapper rwdObjectWdMapper;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private DBUtil dbUtil;
|
|
|
|
|
|
@Value("${binlog.host}")
|
|
@Value("${binlog.host}")
|
|
private String host;
|
|
private String host;
|
|
@@ -117,6 +120,9 @@ public class BinlogClientRunner implements CommandLineRunner {
|
|
binlogPosition = new BinlogPosition();
|
|
binlogPosition = new BinlogPosition();
|
|
}
|
|
}
|
|
binlogPosition.setServerId(serverId);
|
|
binlogPosition.setServerId(serverId);
|
|
|
|
+ //查询binlogName
|
|
|
|
+ String binlogName = dbUtil.queryBinlogName("show binary logs");
|
|
|
|
+ binlogPosition.setBinlogName(binlogName);
|
|
binlogPositionService.saveOrUpdate(binlogPosition);
|
|
binlogPositionService.saveOrUpdate(binlogPosition);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -211,7 +217,6 @@ public class BinlogClientRunner implements CommandLineRunner {
|
|
}
|
|
}
|
|
EventHeaderV4 eventHeaderV4 = (EventHeaderV4) event.getHeader();
|
|
EventHeaderV4 eventHeaderV4 = (EventHeaderV4) event.getHeader();
|
|
binlogPositionSave.setPosition(eventHeaderV4.getPosition());
|
|
binlogPositionSave.setPosition(eventHeaderV4.getPosition());
|
|
-// binlogPositionSave.setBinlogName(event)
|
|
|
|
binlogPositionSave.setServerId(event.getHeader().getServerId());
|
|
binlogPositionSave.setServerId(event.getHeader().getServerId());
|
|
}
|
|
}
|
|
//将最新的配置保存到Redis中
|
|
//将最新的配置保存到Redis中
|
|
@@ -219,13 +224,4 @@ public class BinlogClientRunner implements CommandLineRunner {
|
|
binlogPositionService.saveOrUpdate(binlogPositionSave);
|
|
binlogPositionService.saveOrUpdate(binlogPositionSave);
|
|
}
|
|
}
|
|
|
|
|
|
- private static long getRandomServerId() {
|
|
|
|
- try {
|
|
|
|
- return SecureRandom.getInstanceStrong().nextLong();
|
|
|
|
- } catch (NoSuchAlgorithmException e) {
|
|
|
|
-// return RandomUtils.nextLong();
|
|
|
|
- }
|
|
|
|
- return 0L;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
}
|
|
}
|