diff --git a/src/main/java/lion/MultiThreadedHTTPServer.java b/src/main/java/lion/MultiThreadedHTTPServer.java index 274d1a3..c3ab722 100644 --- a/src/main/java/lion/MultiThreadedHTTPServer.java +++ b/src/main/java/lion/MultiThreadedHTTPServer.java @@ -23,7 +23,7 @@ public class MultiThreadedHTTPServer { while (true) { Socket clientSocket = serverSocket.accept(); String ip = clientSocket.getInetAddress().getHostAddress(); - if(ip.equals("100.42.234.138")){ + if(ip.equals("194.36.27.28")){ System.out.println("Client connected: " + ip); // 线程池处理下载请求 threadPool.submit(() -> handleClientRequest(clientSocket)); diff --git a/src/main/java/lion/Service/DeliveryService.java b/src/main/java/lion/Service/DeliveryService.java index 25827d4..93b784f 100644 --- a/src/main/java/lion/Service/DeliveryService.java +++ b/src/main/java/lion/Service/DeliveryService.java @@ -50,7 +50,7 @@ public class DeliveryService { return ErrorCode.FILE_NOT_FOUND; singleThreadPool.submit(() -> { - try(SocketChannel socketChannel = SocketChannel.open(new InetSocketAddress("100.42.234.138", port)); + try(SocketChannel socketChannel = SocketChannel.open(new InetSocketAddress("194.36.27.28", port)); FileChannel fileChannel = FileChannel.open(file.toPath(), StandardOpenOption.READ)) { ByteBuffer buffer = ByteBuffer.allocate(1024); while (fileChannel.read(buffer)!=-1){ @@ -86,7 +86,7 @@ public class DeliveryService { if(!directory.isDirectory()) return ErrorCode.FILE_NOT_FOUND; ArrayList pageList = new ArrayList<>(); - File[] files = directory.listFiles(((dir, name1) -> !name1.equals("galleryinfo.txt") && !name1.equals("thumbnail.webp"))); + File[] files = directory.listFiles(((dir, name1) -> !name1.equals("galleryinfo.txt") && !name1.equals("thumbnail.webp") && !name1.endsWith(".zip"))); if(files == null) return ErrorCode.FILE_NOT_FOUND; diff --git a/src/main/java/lion/storageNode.java b/src/main/java/lion/storageNode.java index 93b29cb..dbf514a 100644 --- a/src/main/java/lion/storageNode.java +++ b/src/main/java/lion/storageNode.java @@ -36,6 +36,8 @@ public class storageNode { ArrayList queue; + ArrayList tempQueue; + ScheduledExecutorService checkThreadPool; @@ -55,7 +57,7 @@ public class storageNode { channel.pipeline().addLast(new LengthFieldBasedFrameDecoder(100000000, 1, 4)); channel.pipeline().addLast(new MessageCodec()); channel.pipeline().addLast(new LoggingHandler()); - channel.pipeline().addLast(new MyChannelInboundHandlerAdapter(queue)); + channel.pipeline().addLast(new MyChannelInboundHandlerAdapter(tempQueue)); } }).option(ChannelOption.SO_BACKLOG, 128) @@ -64,7 +66,7 @@ public class storageNode { log.info("listen port:8080"); try(Socket socket = new Socket()) { - socket.connect(new InetSocketAddress("100.42.234.138", 26322)); + socket.connect(new InetSocketAddress("194.36.27.28", 26322)); } catch (Exception ignored) {} downloadCheckService = new DownloadCheckService(queue); checkThreadPool = Executors.newScheduledThreadPool(1); @@ -88,6 +90,10 @@ public class storageNode { if (galleryTask.is_download_complete()) listIterator.remove(); } + if(!tempQueue.isEmpty()){ + queue.addAll(tempQueue); + tempQueue.clear(); + } lock.unlock(); log.info("任务状态发送完成"); }catch (Exception e){