try {
LogUtil.debug(getClass().getName(), "Checking deadlines for profile " + profile);
long start = System.currentTimeMillis();
HostManager.setCurrentProfile(profile);
WorkflowManager workflowManager = (WorkflowManager) WorkflowUtil.getApplicationContext().getBean("workflowManager");
int sizeToCheck = 0;
List<String> instancesFailed2check = new ArrayList<String>();
Collection<String> instancesToCheck = workflowManager.getRunningProcessIds();
if (instancesToCheck != null && !instancesToCheck.isEmpty()) {
sizeToCheck = instancesToCheck.size();
Iterator iterProcesses = instancesToCheck.iterator();
List<String> currentBatch = null;
do {
currentBatch = new ArrayList<String>();
try {
for (int n = 0; n < this.instancesPerTransaction; ++n) {
if (!iterProcesses.hasNext()) {
break;
}
String procId = (String) iterProcesses.next();
iterProcesses.remove();
currentBatch.add(procId);
}
String[] pids = new String[currentBatch.size()];
currentBatch.toArray(pids);
workflowManager.internalCheckDeadlines(pids);
} catch (Exception ex) {
LogUtil.error(getClass().getName(), ex, "Profile : " + profile);
instancesFailed2check.addAll(currentBatch);
}
} while (instancesFailed2check.size() <= this.failuresToIgnore && iterProcesses.hasNext());