From d0975287917a7ef42332db5791144237e11d99b6 Mon Sep 17 00:00:00 2001 From: fwhdzh <1064039735@qq.com> Date: Mon, 6 Apr 2026 17:15:32 +0800 Subject: [PATCH 1/2] fix: add some missing exception declaration. --- .../luohaha/paxos/utils/client/ClientImplByLC4J.java | 10 ++-------- .../luohaha/paxos/utils/server/ServerImplByLC4J.java | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/MyPaxos/src/main/java/com/github/luohaha/paxos/utils/client/ClientImplByLC4J.java b/MyPaxos/src/main/java/com/github/luohaha/paxos/utils/client/ClientImplByLC4J.java index 11bbbc8..1424d3a 100644 --- a/MyPaxos/src/main/java/com/github/luohaha/paxos/utils/client/ClientImplByLC4J.java +++ b/MyPaxos/src/main/java/com/github/luohaha/paxos/utils/client/ClientImplByLC4J.java @@ -1,19 +1,13 @@ package com.github.luohaha.paxos.utils.client; import java.io.IOException; -import java.net.UnknownHostException; -import java.nio.channels.ClosedChannelException; import java.util.HashMap; import java.util.Map; -import java.util.Queue; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; import java.util.logging.Level; import com.github.luohaha.client.LightCommClient; import com.github.luohaha.connection.Conn; import com.github.luohaha.exception.ConnectionCloseException; -import com.github.luohaha.inter.OnWrite; import com.github.luohaha.param.ClientParam; public class ClientImplByLC4J implements CommClient { @@ -21,13 +15,13 @@ public class ClientImplByLC4J implements CommClient { private LightCommClient client; private Map addressToConn = new HashMap<>(); - public ClientImplByLC4J(int ioThreadPoolSize) { + public ClientImplByLC4J(int ioThreadPoolSize) throws IOException { // TODO Auto-generated constructor stub this.client = new LightCommClient(ioThreadPoolSize); } @Override - public void sendTo(String ip, int port, byte[] msg) throws ClosedChannelException { + public void sendTo(String ip, int port, byte[] msg) throws IOException { // TODO Auto-generated method stub ClientParam param = new ClientParam(); param.setLogLevel(Level.WARNING); diff --git a/MyPaxos/src/main/java/com/github/luohaha/paxos/utils/server/ServerImplByLC4J.java b/MyPaxos/src/main/java/com/github/luohaha/paxos/utils/server/ServerImplByLC4J.java index 6b8c935..089f198 100644 --- a/MyPaxos/src/main/java/com/github/luohaha/paxos/utils/server/ServerImplByLC4J.java +++ b/MyPaxos/src/main/java/com/github/luohaha/paxos/utils/server/ServerImplByLC4J.java @@ -14,7 +14,7 @@ public class ServerImplByLC4J implements CommServer { private LightCommServer server; private ServerParam serverParam; - public ServerImplByLC4J(int port, int ioThreadPoolSize) { + public ServerImplByLC4J(int port, int ioThreadPoolSize) throws IOException { this.serverParam = new ServerParam("localhost", port); this.serverParam.setLogLevel(Level.WARNING); this.serverParam.setBacklog(128); From 6ab67e216ccb26e0fd192dca1bd816d5c2edfa00 Mon Sep 17 00:00:00 2001 From: fwhdzh <1064039735@qq.com> Date: Mon, 6 Apr 2026 17:20:28 +0800 Subject: [PATCH 2/2] fix: fix usage of Proposer.hasSummitQueue --- .../java/com/github/luohaha/paxos/core/Proposer.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/MyPaxos/src/main/java/com/github/luohaha/paxos/core/Proposer.java b/MyPaxos/src/main/java/com/github/luohaha/paxos/core/Proposer.java index 761b345..3efd4ed 100644 --- a/MyPaxos/src/main/java/com/github/luohaha/paxos/core/Proposer.java +++ b/MyPaxos/src/main/java/com/github/luohaha/paxos/core/Proposer.java @@ -1,7 +1,6 @@ package com.github.luohaha.paxos.core; import java.io.IOException; -import java.lang.Thread.State; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -11,8 +10,6 @@ import java.util.TimerTask; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingQueue; import java.util.logging.Logger; @@ -24,13 +21,8 @@ import com.github.luohaha.paxos.packet.PrepareResponsePacket; import com.github.luohaha.paxos.packet.Value; import com.github.luohaha.paxos.utils.client.CommClient; -import com.github.luohaha.paxos.utils.client.CommClientImpl; import com.github.luohaha.paxos.utils.serializable.ObjectSerialize; import com.github.luohaha.paxos.utils.serializable.ObjectSerializeImpl; -import com.github.luohaha.paxos.utils.server.CommServer; -import com.github.luohaha.paxos.utils.server.CommServerImpl; -import com.github.luohaha.paxos.utils.server.NonBlockServerImpl; -import com.google.gson.Gson; public class Proposer { enum Proposer_State { @@ -191,11 +183,9 @@ public void recvPacket(PacketBean bean) throws InterruptedException { * @return * @throws InterruptedException */ - public Value submit(Value object) throws InterruptedException { + public void submit(Value object) throws InterruptedException { this.readyToSubmitQueue.put(object); beforPrepare(); - Value value = this.hasSummitQueue.take(); - return value; } /**