Skip to content
Snippets Groups Projects
Commit 7976a76c authored by Arnaud Jelmoni's avatar Arnaud Jelmoni
Browse files

PROBLEM-1915 : wait until archiverList is set

parent af0121f8
No related branches found
No related tags found
No related merge requests found
......@@ -12,10 +12,10 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -72,7 +72,7 @@ public abstract class ArchivingManagerApiRef implements IArchivingManagerApiRef
private boolean isConnected;
ScheduledExecutorService executor = Executors.newScheduledThreadPool(5);
ScheduledFuture<?> archiverListRefresher = null;
Future<?> archiverListRefresher = null;
public ArchivingManagerApiRef(final boolean historic, final AbstractDataBaseConnector connector) {
this.historic = historic;
......@@ -524,10 +524,7 @@ public abstract class ArchivingManagerApiRef implements IArchivingManagerApiRef
if (archiverListRefresher != null && !archiverListRefresher.isCancelled()) {
archiverListRefresher.cancel(true);
}
archiverListRefresher = executor.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
archiverListRefresher = executor.submit(() ->{
try {
final boolean facility = isMFacility();
String[] dbExportedArchiverList = getMExportedArchiverList();
......@@ -576,8 +573,7 @@ public abstract class ArchivingManagerApiRef implements IArchivingManagerApiRef
} catch (final DevFailed devFailed) {
devFailed.printStackTrace();
}
}
}, 0, 20, TimeUnit.MILLISECONDS);
});
}
......@@ -606,6 +602,17 @@ public abstract class ArchivingManagerApiRef implements IArchivingManagerApiRef
if (dataBase == null) {
throw new ArchivingException("connection failed");
}
if (archiverListRefresher == null) {
throw new ArchivingException("ArchiverListRefresher not init");
}
try {
archiverListRefresher.get();
} catch (InterruptedException e1) {
archiverListRefresher.cancel(true);
return;
} catch (ExecutionException e1) {
throw new ArchivingException(e1);
}
if (getMExportedArchiverList().length == 0) {
throw new ArchivingException("No archiver running");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment