This commit is contained in:
Michele Artini 2024-01-22 14:52:23 +01:00
parent dc1be1e9b0
commit b4d997efd4
4 changed files with 22 additions and 6 deletions

View File

@ -273,7 +273,11 @@ export class WfHistoryClient extends ISClient {
return;
}
this.httpGet(url, onSuccess);
if (mode == 4) {
this.httpGet(url, (job: WfHistoryEntry) => onSuccess([job]));
} else {
this.httpGet(url, onSuccess);
}
}
findProcess(id: string, onSuccess: Function) {

View File

@ -57,4 +57,12 @@ public class MDStoreManagerClient extends DnetServiceClient {
public MDStoreVersion endReading(final MDStoreVersion version) {
return httpGet("/api/mdstores/version/{versionId}/endReading", MDStoreVersion.class, Map.of("versionId", version.getId()));
}
public boolean existsMdSstore(final String mdId) {
try {
return findMDStore(mdId) != null;
} catch (final Exception e) {
return false;
}
}
}

View File

@ -2,8 +2,8 @@ package eu.dnetlib.wfs.nodes.store;
import org.springframework.beans.factory.annotation.Autowired;
import eu.dnetlib.common.clients.MDStoreManagerClient;
import eu.dnetlib.common.clients.DnetServiceClientFactory;
import eu.dnetlib.common.clients.MDStoreManagerClient;
import eu.dnetlib.wfs.annotations.WfInputParam;
import eu.dnetlib.wfs.annotations.WfNode;
import eu.dnetlib.wfs.nodes.ProcessNode;
@ -19,7 +19,11 @@ public class DeleteMdStoreNode extends ProcessNode {
@Override
protected void execute() throws Exception {
clientFactory.getClient(MDStoreManagerClient.class).deleteMdStore(mdId);
final MDStoreManagerClient client = this.clientFactory.getClient(MDStoreManagerClient.class);
if (client.existsMdSstore(this.mdId)) {
client.deleteMdStore(this.mdId);
}
}
}

View File

@ -10,9 +10,9 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
@ -76,7 +76,7 @@ public class ProcessEngine {
private final Set<String> validNodeTypes = new HashSet<>();
private final ExecutorService wfsThreadPool = Executors.newFixedThreadPool(MAX_RUNNING_WFS);
private final ThreadPoolExecutor wfsThreadPool = (ThreadPoolExecutor) Executors.newFixedThreadPool(MAX_RUNNING_WFS);
@Value("${dnet.wf.procs.size:20}")
private int maxSize;
@ -153,7 +153,7 @@ public class ProcessEngine {
while (true) {
try {
final String processId = this.queue.take();
if (tryToAccept(processId, ServiceStatusRegistry.getStatus().getName())) {
if ((this.wfsThreadPool.getActiveCount() < MAX_RUNNING_WFS) && tryToAccept(processId, ServiceStatusRegistry.getStatus().getName())) {
this.wfsThreadPool.execute(() -> startWorkflowJob(this.jobRepository.findById(processId).get()));
}
} catch (final Throwable e) {