package se.arbetsformedlingen.venice.probe;

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

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() {
        Application gfr = new Application("gfr");
        for (String hostName : Hosts.getGFRHosts()) {
            CheckProbe probe = new CheckProbe(new Host(hostName), gfr);
            probes.add(new ProbeChecker(probe, latestProbeStatuses));
        }

        Application geo = new Application("geo");
        for (String hostName : Hosts.getGFRHosts()) {
            CheckProbe probe = new CheckProbe(new Host(hostName), geo);
            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);
        }
    }

}

@@ -137,20 +137,28 @@
 .common.
-Host
+Applications
 ;%0Aimport
@@ -198,17 +198,16 @@
 mon.Host
-s
 ;%0A%0Aimpor
@@ -668,350 +668,101 @@
     
-Application gfr = new Application(%22gfr%22);%0A        for (String hostName : Hosts.getGFRHosts()) %7B%0A            CheckProbe probe = new CheckProbe(new Host(hostName), gfr);%0A            probes.add(new ProbeChecker(probe, latestProbeStatuses));%0A        %7D%0A%0A        Application geo = new Application(%22geo%22);%0A        for (String hostName : Hosts
+for (Application app : Applications.getApplications()) %7B%0A            for (Host host : app
 .get
-GFR
 Host
@@ -780,16 +780,20 @@
         
+ 
+   
 CheckPro
@@ -822,34 +822,24 @@
 obe(
-new Host(hostName), geo);%0A
+host, app);%0A    
     
@@ -904,16 +904,30 @@
 uses));%0A
+            %7D%0A
         

Use the hosts for each application