Skip to content

Commit 3288388

Browse files
author
Anthony Johnson
committed
Changes for adding support for using unblended costs
1 parent 30e4f0a commit 3288388

File tree

6 files changed

+17
-3
lines changed

6 files changed

+17
-3
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ Options with * require writing your own code.
240240

241241
You may also want to show your organization's throughput metric alongside usage and cost. You can choose to implement interface ThroughputMetricService, or you can simply use the existing BasicThroughputMetricService. Using BasicThroughputMetricService requires the throughput metric data to be stores monthly in files with names like <filePrefix>_2013_04, <filePrefix>_2013_05. Data in files should be delimited by new lines. <filePrefix> is specified when you create BasicThroughputMetricService instance.
242242

243+
9. UnBlended Costs
244+
By default, blended costs are shown. You can show Unblended costs with the following configuration:
245+
246+
ice.use_blended=false
247+
243248
##Support
244249

245250
Please use the [Ice Google Group](https://groups.google.com/d/forum/iceusers) for general questions and discussion.

src/java/com/netflix/ice/basic/BasicLineItemProcessor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class BasicLineItemProcessor implements LineItemProcessor {
5050

5151
private List<String> header;
5252

53-
public void initIndexes(boolean withTags, String[] header) {
53+
public void initIndexes(ProcessorConfig processorConfig, boolean withTags, String[] header) {
5454
boolean hasBlendedCost = false;
5555
for (String column: header) {
5656
if (column.equalsIgnoreCase("UnBlendedCost")) {
@@ -70,6 +70,8 @@ public void initIndexes(boolean withTags, String[] header) {
7070
endTimeIndex = 15 + (withTags ? 0 : -1);
7171
rateIndex = 19 + (withTags ? 0 : -1) + (hasBlendedCost ? 0 : -2);
7272
costIndex = 20 + (withTags ? 0 : -1) + (hasBlendedCost ? 0 : -2);
73+
rateIndex = 19 + (withTags ? 0 : -1) + ((hasBlendedCost && useBlendedCost) ? 0 : -2);
74+
costIndex = 20 + (withTags ? 0 : -1) + ((hasBlendedCost && useBlendedCost) ? 0 : -2);
7375
resourceIndex = 21 + (withTags ? 0 : -1) + (hasBlendedCost ? 0 : -2);
7476

7577
this.header = Lists.newArrayList(header);

src/java/com/netflix/ice/common/IceOptions.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ public class IceOptions {
8080
*/
8181
public static final String CUSTOM_TAGS = "ice.customTags";
8282

83+
/**
84+
* Boolean Flag whether to use blended or Unblended Costs. Default is Blended Cost(true)
85+
*/
86+
public static final String USE_BLENDED = "ice.use_blended";
87+
8388
/**
8489
* s3 bucket name where output files are to be store. Both read and write permissions are needed. It must be specified in Config.
8590
*/

src/java/com/netflix/ice/processor/BillingFileProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ private void processBillingFile(String fileName, InputStream tempIn, boolean wit
568568
reader.readRecord();
569569
String[] headers = reader.getValues();
570570

571-
config.lineItemProcessor.initIndexes(withTags, headers);
571+
config.lineItemProcessor.initIndexes(config, withTags, headers);
572572

573573
while (reader.readRecord()) {
574574
String[] items = reader.getValues();

src/java/com/netflix/ice/processor/LineItemProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public interface LineItemProcessor {
3232
public static final DateTimeFormatter amazonBillingDateFormat = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").withZone(DateTimeZone.UTC);
3333
public static final DateTimeFormatter amazonBillingDateFormat2 = DateTimeFormat.forPattern("yyyy/MM/dd HH:mm:ss").withZone(DateTimeZone.UTC);
3434

35-
void initIndexes(boolean withTags, String[] header);
35+
void initIndexes(ProcessorConfig config, boolean withTags, String[] header);
3636
List<String> getHeader();
3737
int getUserTagStartIndex();
3838
long getEndMillis(String[] items);

src/java/com/netflix/ice/processor/ProcessorConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class ProcessorConfig extends Config {
4141
public final LineItemProcessor lineItemProcessor;
4242
public final Randomizer randomizer;
4343
public final double costPerMonitorMetricPerHour;
44+
public final boolean useBlended;
4445

4546
public final String useCostForResourceGroup;
4647

@@ -85,6 +86,7 @@ public ProcessorConfig(
8586
billingAccessExternalIds = properties.getProperty(IceOptions.BILLING_ACCESS_EXTERNALID, "").split(",");
8687

8788
customTags = properties.getProperty(IceOptions.CUSTOM_TAGS, "").split(",");
89+
useBlended = properties.getProperty(IceOptions.USE_BLENDED) == null ? true : Boolean.parseBoolean(properties.getProperty(IceOptions.USE_BLENDED));
8890

8991
useCostForResourceGroup = properties.getProperty(IceOptions.RESOURCE_GROUP_COST, "modeled");
9092

0 commit comments

Comments
 (0)