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));
}
}
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;
}
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();
}
Aggregations