// Path: agathon-manager/src/main/java/com/brighttag/agathon/dao/CassandraRingDao.java
// public interface CassandraRingDao {
// 
//   /**
//    * Returns the set of Cassandra rings.
//    *
//    * @return set of Cassandra rings
//    * @throws BackingStoreException if there was a problem communicating with the backing store.
//    */
//   ImmutableSet<CassandraRing> findAll() throws BackingStoreException;
// 
//   /**
//    * Returns the Cassandra ring with the given {@code name} or {@code null} if not found.
//    *
//    * @param name the Cassandra ring name
//    * @return the Cassandra ring or {@code null} if not found
//    * @throws BackingStoreException if there was a problem communicating with the backing store.
//    */
//   @Nullable CassandraRing findByName(String name) throws BackingStoreException;
// 
//   /**
//    * Saves the Cassandra {@code ring}.
//    *
//    * @param ring the Cassandra ring
//    */
//   void save(CassandraRing ring);
// 
//   /**
//    * Deletes the Cassandra {@code ring}.
//    *
//    * @param ring the Cassandra ring
//    */
//   void delete(CassandraRing ring);
// 
// }


import java.io.File;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import com.google.common.base.Charsets;
import com.google.common.base.Function;
import com.google.common.cache.CacheBuilder;
import com.google.common.collect.FluentIterable;
import com.google.common.io.Files;
import com.google.common.primitives.Ints;
import com.google.gson.Gson;
import com.google.inject.PrivateModule;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.google.inject.TypeLiteral;
import com.google.inject.name.Named;
import com.google.inject.name.Names;
import com.ning.http.client.AsyncHttpClient;
import com.ning.http.client.AsyncHttpClientConfig;
import com.brighttag.agathon.dao.CassandraInstanceDao;
import com.brighttag.agathon.dao.CassandraRingDao;
import org.joda.time.Duration;
import org.joda.time.format.PeriodFormat;
import org.joda.time.format.PeriodFormatter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static com.google.common.base.Preconditions.checkNotNull;
  static final String ZERG_CACHE_TIMEOUT_PROPERTY = ZERG_PREFIX + "cache_timeout";

  // Internal bindings
  static final String ZERG_CASSANDRA_RING_SCOPES = "ring_scopes";

  // Default values
  static final String ZERG_MANIFEST_URL_DEFAULT = "http://localhost:9374/manifest/environment/prod/";

  private static final Type RING_CONFIG_FILE_TYPE =
      new TypeLiteral<Map<String, Map<String, String>>>() {}.getType();

  @Override
  protected void configure() {
    bind(Gson.class).in(Singleton.class);
    bindConstant().annotatedWith(Names.named(ZERG_MANIFEST_URL_PROPERTY))
        .to(System.getProperty(ZERG_MANIFEST_URL_PROPERTY, ZERG_MANIFEST_URL_DEFAULT));
    bindConstant().annotatedWith(Names.named(ZERG_REGION_PROPERTY))
        .to(checkNotNull(System.getProperty(ZERG_REGION_PROPERTY), "Zerg region not specified"));
    bindConstant().annotatedWith(Names.named(ZERG_RING_CONFIG_PROPERTY))
        .to(checkNotNull(System.getProperty(ZERG_RING_CONFIG_PROPERTY), "Zerg ring config file not specified"));
    // Yes, Zerg is THIS SLOW when the manifest isn't cached, especially in AWS.
    bind(Duration.class).annotatedWith(Names.named(ZERG_REQUEST_TIMEOUT_PROPERTY))
        .toInstance(Duration.standardSeconds(Long.getLong(ZERG_REQUEST_TIMEOUT_PROPERTY, 20)));
    bind(Duration.class).annotatedWith(Names.named(ZERG_CONNECTION_TIMEOUT_PROPERTY))
        .toInstance(Duration.standardSeconds(Long.getLong(ZERG_CONNECTION_TIMEOUT_PROPERTY, 20)));
    bind(Duration.class).annotatedWith(Names.named(ZERG_CACHE_TIMEOUT_PROPERTY))
        .toInstance(Duration.standardMinutes(Long.getLong(ZERG_CACHE_TIMEOUT_PROPERTY, 1)));
    bind(ZergConnector.class).to(ZergConnectorImpl.class).in(Singleton.class);
    bind(CassandraRingDao.class).to(ZergCassandraRingDao.class).in(Singleton.class);
    bind(CassandraInstanceDao.class).to(ZergCassandraInstanceDao.class).in(Singleton.class);
// Path: agathon-manager/src/main/java/com/brighttag/agathon/dao/CassandraRingDao.java
// public interface CassandraRingDao {
// 
//   /**
//    * Returns the set of Cassandra rings.
//    *
//    * @return set of Cassandra rings
//    * @throws BackingStoreException if there was a problem communicating with the backing store.
//    */
//   ImmutableSet<CassandraRing> findAll() throws BackingStoreException;
// 
//   /**
//    * Returns the Cassandra ring with the given {@code name} or {@code null} if not found.
//    *
//    * @param name the Cassandra ring name
//    * @return the Cassandra ring or {@code null} if not found
//    * @throws BackingStoreException if there was a problem communicating with the backing store.
//    */
//   @Nullable CassandraRing findByName(String name) throws BackingStoreException;
// 
//   /**
//    * Saves the Cassandra {@code ring}.
//    *
//    * @param ring the Cassandra ring
//    */
//   void save(CassandraRing ring);
// 
//   /**
//    * Deletes the Cassandra {@code ring}.
//    *
//    * @param ring the Cassandra ring
//    */
//   void delete(CassandraRing ring);
// 
// }


// Path: agathon-manager/src/main/java/com/brighttag/agathon/dao/zerg/ZergDaoModule.java
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import com.google.common.base.Charsets;
import com.google.common.base.Function;
import com.google.common.cache.CacheBuilder;
import com.google.common.collect.FluentIterable;
import com.google.common.io.Files;
import com.google.common.primitives.Ints;
import com.google.gson.Gson;
import com.google.inject.PrivateModule;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.google.inject.TypeLiteral;
import com.google.inject.name.Named;
import com.google.inject.name.Names;
import com.ning.http.client.AsyncHttpClient;
import com.ning.http.client.AsyncHttpClientConfig;
import com.brighttag.agathon.dao.CassandraInstanceDao;
import com.brighttag.agathon.dao.CassandraRingDao;
import org.joda.time.Duration;
import org.joda.time.format.PeriodFormat;
import org.joda.time.format.PeriodFormatter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static com.google.common.base.Preconditions.checkNotNull;

  static final String ZERG_CACHE_TIMEOUT_PROPERTY = ZERG_PREFIX + "cache_timeout";

  // Internal bindings
  static final String ZERG_CASSANDRA_RING_SCOPES = "ring_scopes";

  // Default values
  static final String ZERG_MANIFEST_URL_DEFAULT = "http://localhost:9374/manifest/environment/prod/";

  private static final Type RING_CONFIG_FILE_TYPE =
      new TypeLiteral<Map<String, Map<String, String>>>() {}.getType();

  @Override
  protected void configure() {
    bind(Gson.class).in(Singleton.class);
    bindConstant().annotatedWith(Names.named(ZERG_MANIFEST_URL_PROPERTY))
        .to(System.getProperty(ZERG_MANIFEST_URL_PROPERTY, ZERG_MANIFEST_URL_DEFAULT));
    bindConstant().annotatedWith(Names.named(ZERG_REGION_PROPERTY))
        .to(checkNotNull(System.getProperty(ZERG_REGION_PROPERTY), "Zerg region not specified"));
    bindConstant().annotatedWith(Names.named(ZERG_RING_CONFIG_PROPERTY))
        .to(checkNotNull(System.getProperty(ZERG_RING_CONFIG_PROPERTY), "Zerg ring config file not specified"));
    // Yes, Zerg is THIS SLOW when the manifest isn't cached, especially in AWS.
    bind(Duration.class).annotatedWith(Names.named(ZERG_REQUEST_TIMEOUT_PROPERTY))
        .toInstance(Duration.standardSeconds(Long.getLong(ZERG_REQUEST_TIMEOUT_PROPERTY, 20)));
    bind(Duration.class).annotatedWith(Names.named(ZERG_CONNECTION_TIMEOUT_PROPERTY))
        .toInstance(Duration.standardSeconds(Long.getLong(ZERG_CONNECTION_TIMEOUT_PROPERTY, 20)));
    bind(Duration.class).annotatedWith(Names.named(ZERG_CACHE_TIMEOUT_PROPERTY))
        .toInstance(Duration.standardMinutes(Long.getLong(ZERG_CACHE_TIMEOUT_PROPERTY, 1)));
    bind(ZergConnector.class).to(ZergConnectorImpl.class).in(Singleton.class);
    bind(CassandraRingDao.class).to(ZergCassandraRingDao.class).in(Singleton.class);
    bind(CassandraInstanceDao.class).to(ZergCassandraInstanceDao.class).in(Singleton.class);
    expose(CassandraRingDao.class);