Browse Source

Wake threads that are waiting for available space to add job reports to postQueue.

tags/Production_2016_10_17
ymlam 9 years ago
parent
commit
f49203affa
1 changed files with 34 additions and 9 deletions
  1. +34
    -9
      src/altk/comm/engine/postback/PostBack.java

+ 34
- 9
src/altk/comm/engine/postback/PostBack.java View File

@@ -108,7 +108,11 @@ public class PostBack
if (report == null) break; if (report == null) break;
reportList.add(report); reportList.add(report);
} }
if (reportList.size() > 0) break; // break out to do the work.
if (reportList.size() > 0)
{
postQueue.notify();
break; // break out to do the work.
}
// Nothing to do, so wait a while, and look at the // Nothing to do, so wait a while, and look at the
// queue again. // queue again.
@@ -136,8 +140,11 @@ public class PostBack
case SERVER_IO_ERROR: case SERVER_IO_ERROR:
// TODO: Limit retries, using rate limiting. Posting can be recovered using the activity log. // TODO: Limit retries, using rate limiting. Posting can be recovered using the activity log.
// Re-queue this job
queueReports(reportList);
// Re-queue these reports
for (String rpt : reportList)
{
queueReport(rpt);
}
// Sleep for a while before retrying this PostBack server. // Sleep for a while before retrying this PostBack server.
CommonLogger.alarm.warn(getName() + ": Caught server IO error. sleep for " + POSTBACK_SERVER_WAIT_TIME + " seconds"); CommonLogger.alarm.warn(getName() + ": Caught server IO error. sleep for " + POSTBACK_SERVER_WAIT_TIME + " seconds");
try try
@@ -372,14 +379,29 @@ public class PostBack
myLogger.debug(myName + ": postQueue size: " + postQueue.size()); myLogger.debug(myName + ": postQueue size: " + postQueue.size());
synchronized(postQueue) synchronized(postQueue)
{ {
if (postQueue.size() < maxQueueSize)
{
postQueue.add(report);
postQueue.notify();
return true;
for (;;)
{
if (postQueue.size() < maxQueueSize)
{
postQueue.add(report);
postQueue.notify();
return true;
}
else
{
myLogger.debug("Waiting for space in postQueue to queue report");
try
{
postQueue.wait();
}
catch (InterruptedException e)
{
break;
}
}
} }
} }
CommonLogger.alarm.warn(myName + ".queueReport method returning false");
myLogger.error("Interrupted while waiting for space to queue report");
return false; return false;
} }
@@ -389,6 +411,8 @@ public class PostBack
* @param reports to be added back to postQueue * @param reports to be added back to postQueue
* @return true if all jobs have been added to queue, false otherwise (queue full) * @return true if all jobs have been added to queue, false otherwise (queue full)
*/ */
/*
@Deprecated
public boolean queueReports(List<String> reports) public boolean queueReports(List<String> reports)
{ {
myLogger.debug(myName + ": postQueue size: " + postQueue.size()); myLogger.debug(myName + ": postQueue size: " + postQueue.size());
@@ -416,6 +440,7 @@ public class PostBack
return returnValue; return returnValue;
} }
} }
*/


public void terminate() public void terminate()
{ {


Loading…
Cancel
Save