Added support to NoContext in root scope
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/accounting-manager@142589 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
cf8e664241
commit
9d79ef0cf0
|
@ -1,5 +1,6 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
@ -31,10 +32,13 @@ public class AccountingClientDaemon implements Runnable {
|
|||
private ServletContextEvent sce;
|
||||
private volatile boolean running = true;
|
||||
private volatile AccountingCache accountingCache;
|
||||
private ArrayList<Future<TaskStatus>> workers;
|
||||
|
||||
public AccountingClientDaemon(ServletContextEvent sce, AccountingCache accountingCache) {
|
||||
public AccountingClientDaemon(ServletContextEvent sce,
|
||||
AccountingCache accountingCache) {
|
||||
this.sce = sce;
|
||||
this.accountingCache = accountingCache;
|
||||
workers = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void terminate() {
|
||||
|
@ -58,23 +62,38 @@ public class AccountingClientDaemon implements Runnable {
|
|||
taskRequest, accountingCache);
|
||||
Future<TaskStatus> futureResult = executorService
|
||||
.submit(accountingClientCallable);
|
||||
workers.add(futureResult);
|
||||
|
||||
}
|
||||
|
||||
if (!workers.isEmpty()) {
|
||||
ArrayList<Future<TaskStatus>> dones=new ArrayList<>();
|
||||
for (Future<TaskStatus> futureResult : workers) {
|
||||
if (futureResult.isDone()) {
|
||||
TaskStatus result = null;
|
||||
try {
|
||||
result = futureResult.get(Constants.SERVICE_CLIENT_TIMEOUT_DEFAULT_MINUTES,
|
||||
result = futureResult
|
||||
.get(Constants.SERVICE_CLIENT_TIMEOUT_DEFAULT_MINUTES,
|
||||
TimeUnit.MINUTES);
|
||||
logger.info("AccountingClientTask: " + result);
|
||||
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
logger.error(
|
||||
"AccountingClientTask: " + e.getLocalizedMessage(),
|
||||
e);
|
||||
"AccountingClientTask: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
} catch (TimeoutException e) {
|
||||
logger.error("AccountingClientTask No response after "
|
||||
+ Constants.SERVICE_CLIENT_TIMEOUT_DEFAULT_MINUTES + " minutes!");
|
||||
+ Constants.SERVICE_CLIENT_TIMEOUT_DEFAULT_MINUTES
|
||||
+ " minutes!");
|
||||
futureResult.cancel(true);
|
||||
}
|
||||
dones.add(futureResult);
|
||||
}
|
||||
}
|
||||
workers.removeAll(dones);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue