package se.arbetsformedlingen.venice.probe;

import se.arbetsformedlingen.venice.common.Application;
import se.arbetsformedlingen.venice.common.Applications;
import se.arbetsformedlingen.venice.common.Host;

import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class ProbeCheckScheduler {
    private LatestProbeStatuses latestProbeStatuses = new LatestProbeStatuses();
    private List<ProbeChecker> probes = new LinkedList<>();

    public ProbeCheckScheduler() {
        addProbes();
    }

    private void addProbes() {
        for (Application app : Applications.getApplications()) {
            for (Host host : app.getHosts()) {
                CheckProbe probe = new CheckProbe(host, app);
                probes.add(new ProbeChecker(probe, latestProbeStatuses));
            }
        }
    }

    public void startChecking(int period, TimeUnit unit) {
        ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(11);
        for (ProbeChecker probe : probes) {
            scheduler.scheduleAtFixedRate(probe, 1, period, unit);
        }
    }

}

@@ -199,16 +199,70 @@
 on.Host;
+%0Aimport se.arbetsformedlingen.venice.common.Scheduler;
 %0A%0Aimport
@@ -472,16 +472,37 @@
 heduler 
+implements Scheduler 
 %7B%0A    pr
@@ -1006,24 +1006,38 @@
    %7D%0A    %7D%0A%0A
+    @Override%0A
     public v
@@ -1287,17 +1287,16 @@
       %7D%0A
+
     %7D%0A
-%0A
 %7D%0A

Implement a common interface