// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java
// public class ServiceId {
//     private final String id;
// 
//     private ServiceId(String id) {
//         this.id = id;
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public static ServiceId from(String id) {
//         return new ServiceId(id);
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(id);
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (this == obj) {
//             return true;
//         }
//         if (obj == null || getClass() != obj.getClass()) {
//             return false;
//         }
//         final ServiceId other = (ServiceId) obj;
//         return Objects.equals(this.id, other.id);
//     }
// 
//     @Override
//     public String toString() {
//         return id;
//     }
// }
// 
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/TurbineInstanceDiscovery.java
// public class TurbineInstanceDiscovery {
//     private static final Logger LOGGER = LoggerFactory.getLogger(TurbineInstanceDiscovery.class);
//     public static final String BREAKERBOX_INSTANCE_ID = "Breakerbox-Instance-Id";
//     public static final String DEFAULT_URL_SUFFIX = "/tenacity/metrics.stream";
// 
//     private TurbineInstanceDiscovery() {}
// 
//     public static void registerClusters(Collection<String> clusterNames) {
//         registerClusters(clusterNames, DEFAULT_URL_SUFFIX);
//     }
// 
//     public static void registerClusters(Collection<String> clusterNames,
//                                         String instanceUrlSuffix) {
//         final AbstractConfiguration configurationManager = ConfigurationManager.getConfigInstance();
//         configurationManager.setProperty(InstanceDiscovery.TURBINE_AGGREGATOR_CLUSTER_CONFIG,
//                 Joiner.on(',').join(clusterNames));
//         configurationManager.setProperty("turbine.instanceUrlSuffix", instanceUrlSuffix);
//         final ClusterMonitorFactory<?> clusterMonitorFactory = PluginsFactory.getClusterMonitorFactory();
//         if (clusterMonitorFactory != null) {
//             try {
//                 clusterMonitorFactory.initClusterMonitors();
//             } catch (Exception err) {
//                 LOGGER.error("Trouble initializing cluster monitors", err);
//             }
//         }
//     }
// }


import com.google.common.collect.ImmutableList;
import com.netflix.turbine.discovery.Instance;
import com.netflix.turbine.plugins.PluginsFactory;
import com.yammer.breakerbox.store.ServiceId;
import com.yammer.breakerbox.turbine.TurbineInstanceDiscovery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collection;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;
package com.yammer.breakerbox.service.core;



public class Instances {
    private static final Logger LOGGER = LoggerFactory.getLogger(Instances.class);

    public static Collection<Instance> instances() {
        try {
            return PluginsFactory.getInstanceDiscovery().getInstanceList();
        } catch (Exception err) {
            LOGGER.warn("Could not fetch clusters dynamically", err);
        }

        return ImmutableList.of();
    }

    public static Collection<String> clusters() {
        return instances()
                .stream()
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java
// public class ServiceId {
//     private final String id;
// 
//     private ServiceId(String id) {
//         this.id = id;
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public static ServiceId from(String id) {
//         return new ServiceId(id);
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(id);
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (this == obj) {
//             return true;
//         }
//         if (obj == null || getClass() != obj.getClass()) {
//             return false;
//         }
//         final ServiceId other = (ServiceId) obj;
//         return Objects.equals(this.id, other.id);
//     }
// 
//     @Override
//     public String toString() {
//         return id;
//     }
// }
// 
// Path: breakerbox-turbine/src/main/java/com/yammer/breakerbox/turbine/TurbineInstanceDiscovery.java
// public class TurbineInstanceDiscovery {
//     private static final Logger LOGGER = LoggerFactory.getLogger(TurbineInstanceDiscovery.class);
//     public static final String BREAKERBOX_INSTANCE_ID = "Breakerbox-Instance-Id";
//     public static final String DEFAULT_URL_SUFFIX = "/tenacity/metrics.stream";
// 
//     private TurbineInstanceDiscovery() {}
// 
//     public static void registerClusters(Collection<String> clusterNames) {
//         registerClusters(clusterNames, DEFAULT_URL_SUFFIX);
//     }
// 
//     public static void registerClusters(Collection<String> clusterNames,
//                                         String instanceUrlSuffix) {
//         final AbstractConfiguration configurationManager = ConfigurationManager.getConfigInstance();
//         configurationManager.setProperty(InstanceDiscovery.TURBINE_AGGREGATOR_CLUSTER_CONFIG,
//                 Joiner.on(',').join(clusterNames));
//         configurationManager.setProperty("turbine.instanceUrlSuffix", instanceUrlSuffix);
//         final ClusterMonitorFactory<?> clusterMonitorFactory = PluginsFactory.getClusterMonitorFactory();
//         if (clusterMonitorFactory != null) {
//             try {
//                 clusterMonitorFactory.initClusterMonitors();
//             } catch (Exception err) {
//                 LOGGER.error("Trouble initializing cluster monitors", err);
//             }
//         }
//     }
// }


// Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/core/Instances.java
import com.google.common.collect.ImmutableList;
import com.netflix.turbine.discovery.Instance;
import com.netflix.turbine.plugins.PluginsFactory;
import com.yammer.breakerbox.store.ServiceId;
import com.yammer.breakerbox.turbine.TurbineInstanceDiscovery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collection;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;

package com.yammer.breakerbox.service.core;



public class Instances {
    private static final Logger LOGGER = LoggerFactory.getLogger(Instances.class);

    public static Collection<Instance> instances() {
        try {
            return PluginsFactory.getInstanceDiscovery().getInstanceList();
        } catch (Exception err) {
            LOGGER.warn("Could not fetch clusters dynamically", err);
        }

        return ImmutableList.of();
    }

    public static Collection<String> clusters() {
        return instances()
                .stream()
                .map(Instance::getCluster)