Search in sources :

Example 6 with Product

use of com.netflix.ice.tag.Product in project ice by Netflix.

the class EddaResourceServiceTest method test.

@Test
public void test() throws Exception {
    EddaResourceService service = new EddaResourceService(new Properties());
    service.init();
    // does nothing really...
    service.commit();
    assertNotNull(service.getProductsWithResources());
    assertEquals("Product-name for unsupported resource", "somename", service.getResource(null, null, new Product("somename"), null, null, 0));
    assertEquals("Error for empty resourceId", "Error", service.getResource(null, null, Product.ec2, null, null, 0));
    assertEquals("Error for empty resourceId", "Error", service.getResource(null, null, Product.ec2, "", null, 0));
    assertEquals("Unknown for resourceIds that we do not find", "Unknown", service.getResource(null, null, Product.ec2, "someunknowninstance", null, 0));
    JSONArray instances = service.readInstanceArray();
    String resource = service.getResource(null, null, Product.ec2, instances.getString(0), null, 0);
    assertFalse("Not Error for an actual instance", "Error".equals(resource));
    resource = service.getResource(null, null, Product.ec2_instance, instances.getString(0), null, 0);
    assertFalse("Not Error for an actual instance", "Error".equals(resource));
    for (int i = 0; i < instances.length(); i++) {
        resource = service.getResource(null, null, Product.ec2_instance, instances.getString(i), null, 0);
        assertFalse("Not Error for an actual instance", "Error".equals(resource));
    }
}
Also used : JSONArray(com.amazonaws.util.json.JSONArray) Product(com.netflix.ice.tag.Product) Properties(java.util.Properties) Test(org.junit.Test)

Example 7 with Product

use of com.netflix.ice.tag.Product in project ice by Netflix.

the class BasicProductService method getProductByName.

public Product getProductByName(String name) {
    Product product = productsByName.get(name);
    if (product == null) {
        product = new Product(name);
        productsByAwsName.put(name, product);
        productsByName.put(name, product);
    }
    return product;
}
Also used : Product(com.netflix.ice.tag.Product)

Example 8 with Product

use of com.netflix.ice.tag.Product in project ice by Netflix.

the class ReaderConfig method start.

public void start() {
    Managers managers = ReaderConfig.getInstance().managers;
    Collection<Product> products = managers.getProducts();
    for (Product product : products) {
        TagGroupManager tagGroupManager = managers.getTagGroupManager(product);
        Interval interval = tagGroupManager.getOverlapInterval(new Interval(new DateTime(DateTimeZone.UTC).minusMonths(monthlyCacheSize), new DateTime(DateTimeZone.UTC)));
        if (interval == null)
            continue;
        for (ConsolidateType consolidateType : ConsolidateType.values()) {
            readData(product, managers.getCostManager(product, consolidateType), interval, consolidateType);
            readData(product, managers.getUsageManager(product, consolidateType), interval, consolidateType);
        }
    }
    if (costEmailService != null)
        costEmailService.start();
}
Also used : Product(com.netflix.ice.tag.Product) DateTime(org.joda.time.DateTime) Interval(org.joda.time.Interval)

Aggregations

Product (com.netflix.ice.tag.Product)8 DateTime (org.joda.time.DateTime)3 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)1 S3ObjectSummary (com.amazonaws.services.s3.model.S3ObjectSummary)1 JSONArray (com.amazonaws.util.json.JSONArray)1 Properties (java.util.Properties)1 Interval (org.joda.time.Interval)1 Test (org.junit.Test)1