调整初始化顺序,避免重连时有未完成的任务导致初始化失败;修复发送未完成任务时不带名字的bug

This commit is contained in:
chuzhongzai 2025-08-29 16:15:59 +08:00
parent d7ba01be2d
commit 3bdaddaead

View File

@ -19,6 +19,7 @@ import org.springframework.stereotype.Service;
import java.io.IOException;
import java.net.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -87,10 +88,11 @@ public class RemoteService {
if(pushService != null)
pushService.storageNodeOnline();
//子节点上线时发送未完成的任务
resetUndone();
channel = channelFuture.channel();
channel.writeAndFlush(new IdentityMessage("lionwebsite"));
//子节点上线时发送未完成的任务
resetUndone();
return true;
}catch (Exception e){
e.printStackTrace();
@ -110,6 +112,7 @@ public class RemoteService {
Gallery[] galleries = galleryMapper.selectUnDoneGalleries();
if(galleries != null && galleries.length != 0) {
log.info("发送未下载完成图片至节点,{}本", galleries.length);
log.info("{}", Arrays.toString(galleries));
for (Gallery gallery : galleries)
addGalleryToQueue(gallery);
}
@ -118,6 +121,7 @@ public class RemoteService {
public byte addGalleryToQueue(Gallery gallery){
GalleryTask galleryTask = new GalleryTask();
galleryTask.setGid(gallery.getGid());
galleryTask.setName(gallery.getName());
DownloadPostMessage dpm = new DownloadPostMessage();
dpm.messageId = atomicInteger.getAndIncrement();