提交 b76ab0d1 编写于 作者: J João Sousa

tweeks

上级 9da01359
无法预览此类型文件
......@@ -32,6 +32,7 @@ import bftsmart.tom.server.RequestVerifier;
import bftsmart.tom.util.TOMUtil;
import java.nio.ByteBuffer;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -44,6 +45,7 @@ public class ClientsManager {
private Logger logger = LoggerFactory.getLogger(this.getClass());
private boolean doWork = true;
private ServerViewController controller;
private RequestsTimer timer;
private HashMap<Integer, ClientData> clientsData = new HashMap<Integer, ClientData>();
......@@ -73,13 +75,15 @@ public class ClientsManager {
public void run() {
while (true) {
while (doWork) {
try {
TOMMessage request = ackQueue.take();
cs.send(new int[]{request.getSender()}, request.reply);
TOMMessage request = null;
request = ackQueue.poll(100,TimeUnit.MILLISECONDS);
if (request != null)
cs.send(new int[]{request.getSender()}, request.reply);
} catch (InterruptedException ex) {
java.util.logging.Logger.getLogger(ClientsManager.class.getName()).log(Level.SEVERE, null, ex);
logger.error("Interrupted exception", ex);
}
}
}
......@@ -479,10 +483,8 @@ public class ClientsManager {
ackQueue.put(clone);
} catch (InterruptedException ex) {
java.util.logging.Logger.getLogger(ClientsManager.class.getName()).log(Level.SEVERE, null, ex);
} catch (CloneNotSupportedException ex) {
java.util.logging.Logger.getLogger(ClientsManager.class.getName()).log(Level.SEVERE, null, ex);
} catch (InterruptedException | CloneNotSupportedException ex) {
logger.error("Error while sending ACK", ex);
}
request.ackSent = true;
......@@ -544,4 +546,12 @@ public class ClientsManager {
return clientsData.size();
}
public void shutdown() {
clear();
getPendingRequests().clear();
doWork = false;
}
}
......@@ -627,10 +627,7 @@ public final class TOMLayer extends Thread implements RequestReceiver {
setNoExec();
if (this.requestsTimer != null) this.requestsTimer.shutdown();
if (this.clientsManager != null) {
this.clientsManager.clear();
this.clientsManager.getPendingRequests().clear();
}
if (this.clientsManager != null) this.clientsManager.shutdown();
if (this.dt != null) this.dt.shutdown();
if (this.communication != null) this.communication.shutdown();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册