|
|
|
@@ -43,9 +43,6 @@ import org.apache.log4j.Logger; |
|
|
|
import org.w3c.dom.Document; |
|
|
|
import org.w3c.dom.Node; |
|
|
|
|
|
|
|
import altk.comm.engine.Broadcast.BroadcastState; |
|
|
|
import altk.comm.engine.CommonLogger; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Queues JobReports to be posted back to attribute postBackURL. |
|
|
|
@@ -124,85 +121,12 @@ public class Postback |
|
|
|
List<String> reportList = new ArrayList<String>(); |
|
|
|
synchronized(postQueue) |
|
|
|
{ |
|
|
|
// Each iteration examines the queue for a batch to send |
|
|
|
//for (;;) |
|
|
|
//{ |
|
|
|
//reportList = new ArrayList<String>(); |
|
|
|
for (int i = 0; i < maxBatchSize ; i++) |
|
|
|
{ |
|
|
|
report = postQueue.poll(); |
|
|
|
if (report == null) break; |
|
|
|
reportList.add(report); |
|
|
|
} |
|
|
|
/* |
|
|
|
if (reportList.size() > 0) |
|
|
|
{ |
|
|
|
myLogger.debug(String.format("Extracted %d reports, reducing postQueue size: %d", reportList.size(), postQueue.size())); |
|
|
|
postQueue.notifyAll(); |
|
|
|
break; // break out to do the work. |
|
|
|
}TODO Auto-generated catch block |
|
|
|
|
|
|
|
// No reports |
|
|
|
BroadcastState toState = null; |
|
|
|
String reason = null; |
|
|
|
switch (broadcast.getState()) |
|
|
|
{ |
|
|
|
case ALLDONE: |
|
|
|
toState = BroadcastState.COMPLETED; |
|
|
|
reason = "All posted"; |
|
|
|
break; |
|
|
|
case CANCELING: |
|
|
|
if (broadcast.getActiveJobCount() > 0) break; |
|
|
|
toState = BroadcastState.CANCELED; |
|
|
|
reason = "User canceled"; |
|
|
|
break; |
|
|
|
case PAUSING: |
|
|
|
if (broadcast.getActiveJobCount() > 0) break; |
|
|
|
toState = BroadcastState.PAUSED; |
|
|
|
reason = "User paused"; |
|
|
|
break; |
|
|
|
default: |
|
|
|
} |
|
|
|
if (toState != null) |
|
|
|
{ |
|
|
|
if (toState.isFinal) |
|
|
|
{ |
|
|
|
broadcast.terminate(toState, reason); |
|
|
|
myLogger.info("All posted, thread terminating"); |
|
|
|
return; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
broadcast.setState(toState); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (broadcast.getState().isFinal) |
|
|
|
{ |
|
|
|
// No more. Notify all waiting postback threads and exit thread |
|
|
|
myLogger.info("All posted, thread terminating"); |
|
|
|
postQueue.notifyAll(); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// Nothing to do, so wait a while, and look at the |
|
|
|
// queue again. |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
myLogger.debug("Going to wait " + QUEUE_WAIT * 1000); |
|
|
|
postQueue.wait(); //QUEUE_WAIT * 1000); |
|
|
|
} |
|
|
|
catch (InterruptedException e) |
|
|
|
{ |
|
|
|
CommonLogger.alarm.info("Postback queue interrupted while waiting: " + e); |
|
|
|
break; |
|
|
|
} |
|
|
|
CommonLogger.health.info("Surfacing from wait"); |
|
|
|
System.out.println(getName() + " surfacing from wait"); |
|
|
|
continue; |
|
|
|
*/ |
|
|
|
// } |
|
|
|
for (int i = 0; i < maxBatchSize ; i++) |
|
|
|
{ |
|
|
|
report = postQueue.poll(); |
|
|
|
if (report == null) break; |
|
|
|
reportList.add(report); |
|
|
|
} |
|
|
|
} // synchronized() |
|
|
|
if (reportList.size() > 0) |
|
|
|
{ |
|
|
|
@@ -213,14 +137,6 @@ public class Postback |
|
|
|
break; |
|
|
|
|
|
|
|
case SERVER_IO_ERROR: |
|
|
|
/* Should not requeue report for this may lead to dead lock on this queu. |
|
|
|
// TODO: Limit retries, using rate limiting. Posting can be recovered using the activity log. |
|
|
|
// Re-queue these reports |
|
|
|
for (String rpt : reportList) |
|
|
|
{ |
|
|
|
queueReport(rpt); |
|
|
|
} |
|
|
|
*/ |
|
|
|
// Sleep for a while before retrying this PostBack server. |
|
|
|
CommonLogger.alarm.warn("Caught server IO error. sleep for " + POSTBACK_SERVER_WAIT_TIME + " seconds"); |
|
|
|
try |
|
|
|
|