From a0960cadef3365a499c6bd0b2adda39425ef8203 Mon Sep 17 00:00:00 2001 From: clemenso Date: Fri, 5 Sep 2008 13:29:01 +0000 Subject: TIMEOUT git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@18 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../egiz/stal/service/impl/STALRequestBroker.java | 10 ++++----- .../stal/service/impl/STALRequestBrokerImpl.java | 26 +++++++++++----------- 2 files changed, 17 insertions(+), 19 deletions(-) (limited to 'BKUOnline') diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBroker.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBroker.java index aad9b874..6aabdae4 100644 --- a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBroker.java +++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBroker.java @@ -20,12 +20,11 @@ */ package at.gv.egiz.stal.service.impl; +import at.gv.egiz.stal.HashDataInput; import at.gv.egiz.stal.STAL; import at.gv.egiz.stal.STALRequest; import at.gv.egiz.stal.STALResponse; -import at.gv.egiz.stal.HashDataInputCallback; import java.util.List; -import java.util.concurrent.TimeoutException; /** * @@ -34,10 +33,9 @@ import java.util.concurrent.TimeoutException; public interface STALRequestBroker extends STAL { public static final int ERR_6000 = 6000; - public static final long TIMEOUT_MS = 1000*60*5; //300000; + public static final long TIMEOUT_MS = 1000*60*3; //3mn public List nextRequest(List response); -// public void setResponse(List response) throws TimeoutException; -// public void interruptRequestHandling(ErrorResponseType error); - public HashDataInputCallback getHashDataInput(); + + public List getHashDataInput(); } diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java index 19548247..9601d39c 100644 --- a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java +++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java @@ -21,10 +21,10 @@ package at.gv.egiz.stal.service.impl; import at.gv.egiz.stal.ErrorResponse; +import at.gv.egiz.stal.HashDataInput; import at.gv.egiz.stal.QuitRequest; import at.gv.egiz.stal.STALRequest; import at.gv.egiz.stal.STALResponse; -import at.gv.egiz.stal.HashDataInputCallback; import at.gv.egiz.stal.SignRequest; import java.util.ArrayList; import java.util.Collections; @@ -50,7 +50,7 @@ public class STALRequestBrokerImpl implements STALRequestBroker { // protected RequestResponseBroker broker; protected List requests = null; protected List responses = null; - protected HashDataInputCallback currentHashDataInputCallback; + protected List currentHashDataInput; private boolean isHandlingRequest = false; private boolean expectingResponse = false; // private Object handleRequestCondition = new Object(); @@ -75,10 +75,10 @@ public class STALRequestBrokerImpl implements STALRequestBroker { */ @Override public synchronized List handleRequest(List requests) { + long beforeWait = System.currentTimeMillis(); while (isHandlingRequest) { log.trace("waiting to produce request"); try { - long beforeWait = System.currentTimeMillis(); wait(TIMEOUT_MS); if (System.currentTimeMillis() - beforeWait >= TIMEOUT_MS) { log.warn("timeout while waiting to produce request"); @@ -92,11 +92,11 @@ public class STALRequestBrokerImpl implements STALRequestBroker { isHandlingRequest = true; this.requests = requests; - currentHashDataInputCallback = null; + currentHashDataInput = null; for (STALRequest request : requests) { if (request instanceof SignRequest) { log.trace("Received SignRequest, keep HashDataInput callback."); - currentHashDataInputCallback = ((SignRequest) request).getHashDataInput(); + currentHashDataInput = ((SignRequest) request).getHashDataInput(); break; } else if (request instanceof QuitRequest) { //alternative1: @@ -107,7 +107,7 @@ public class STALRequestBrokerImpl implements STALRequestBroker { notify(); //alternative2: //wait for QUIT to be consumed - // (i.e. notify me noce QUIT is consumed) + // (i.e. notify me once QUIT is consumed) // while (this.requests != null) { // try { // long beforeWait = System.currentTimeMillis(); @@ -131,15 +131,15 @@ public class STALRequestBrokerImpl implements STALRequestBroker { log.trace("notifying request consumers"); notify(); + beforeWait = System.currentTimeMillis(); while (this.responses == null) { log.trace("waiting to consume response"); try { - long beforeWait = System.currentTimeMillis(); wait(TIMEOUT_MS); if (System.currentTimeMillis() - beforeWait >= TIMEOUT_MS) { log.warn("timeout while waiting to consume response"); this.requests = null; - currentHashDataInputCallback = null; + currentHashDataInput = null; isHandlingRequest = false; return Collections.singletonList((STALResponse) new ErrorResponse(ERR_6000)); } @@ -172,10 +172,10 @@ public class STALRequestBrokerImpl implements STALRequestBroker { log.warn("Received unexpected response in nextRequest()"); return Collections.singletonList((STALRequest) new QuitRequest()); } + long beforeWait = System.currentTimeMillis(); while (this.responses != null) { log.trace("waiting to produce response"); try { - long beforeWait = System.currentTimeMillis(); wait(TIMEOUT_MS); if (System.currentTimeMillis() - beforeWait >= TIMEOUT_MS) { log.warn("timeout while waiting to produce response"); @@ -204,10 +204,10 @@ public class STALRequestBrokerImpl implements STALRequestBroker { log.trace("expecting non-null response in next nextRequest(response)"); expectingResponse = true; } + long beforeWait = System.currentTimeMillis(); while (this.requests == null) { log.trace("waiting to consume request"); try { - long beforeWait = System.currentTimeMillis(); wait(TIMEOUT_MS); if (System.currentTimeMillis() - beforeWait >= TIMEOUT_MS) { log.warn("timeout while waiting to consume request"); @@ -239,9 +239,9 @@ public class STALRequestBrokerImpl implements STALRequestBroker { } @Override - public synchronized HashDataInputCallback getHashDataInput() { - log.trace("return current HashDataInput callback"); - return currentHashDataInputCallback; + public synchronized List getHashDataInput() { + log.trace("return " + currentHashDataInput.size() + " current HashDataInput(s) "); + return currentHashDataInput; } // /** // * Causes the calling thread to sleep until response is passed via nextRequest() -- cgit v1.2.3