Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add code for addressing services with '/' #137

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/java/com/netflix/ice/basic/BasicDataManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public ReadOnlyData load(DateTime monthDate) throws Exception {
public BasicDataManager(Product product, ConsolidateType consolidateType, boolean isCost) {
this.product = product;
this.consolidateType = consolidateType;
this.dbName = (isCost ? "cost_" : "usage_") + consolidateType + "_" + (product == null ? "all" : product.name);
this.dbName = (isCost ? "cost_" : "usage_") + consolidateType + "_" + (product == null ? "all" : product.s3Name);

start(300);
}
Expand Down
1 change: 1 addition & 0 deletions src/java/com/netflix/ice/basic/BasicManagers.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ private void doWork() {
}
else {
String name = key.substring((config.workS3BucketPrefix + TagGroupWriter.DB_PREFIX).length());
name = name.replaceAll("--", "/");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tag.fromS3()

product = config.productService.getProductByName(name);
}
if (!products.contains(product)) {
Expand Down
2 changes: 1 addition & 1 deletion src/java/com/netflix/ice/basic/BasicTagGroupManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class BasicTagGroupManager extends Poller implements TagGroupManager {
private Interval totalInterval;

BasicTagGroupManager(Product product) {
this.dbName = TagGroupWriter.DB_PREFIX + (product == null ? "all" : product.name);
this.dbName = TagGroupWriter.DB_PREFIX + (product == null ? "all" : product.s3Name);
file = new File(config.localDir, dbName);
try {
poll();
Expand Down
4 changes: 2 additions & 2 deletions src/java/com/netflix/ice/processor/BillingFileProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ private void archive() throws Exception {
private void archiveHourly(Map<Product, ReadWriteData> dataMap, String prefix) throws Exception {
DateTime monthDateTime = new DateTime(startMilli, DateTimeZone.UTC);
for (Product product: dataMap.keySet()) {
String prodName = product == null ? "all" : product.name;
String prodName = product == null ? "all" : product.s3Name;
DataWriter writer = new DataWriter(prefix + "hourly_" + prodName + "_" + AwsUtils.monthDateFormat.print(monthDateTime), false);
writer.archive(dataMap.get(product));
}
Expand All @@ -447,7 +447,7 @@ private void archiveSummary(Map<Product, ReadWriteData> dataMap, String prefix)

for (Product product: dataMap.keySet()) {

String prodName = product == null ? "all" : product.name;
String prodName = product == null ? "all" : product.s3Name;
ReadWriteData data = dataMap.get(product);
Collection<TagGroup> tagGroups = data.getTagGroups();

Expand Down
2 changes: 1 addition & 1 deletion src/java/com/netflix/ice/processor/DataWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class DataWriter {
private ReadWriteData data;

DataWriter(String name, boolean loadData) throws Exception {

name = name.replaceAll("/", "--");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it's better call Tag.toS3() method instead

dbName = name;
file = new File(config.localDir, dbName);
if (loadData) {
Expand Down
3 changes: 2 additions & 1 deletion src/java/com/netflix/ice/processor/TagGroupWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.google.common.collect.Maps;
import com.netflix.ice.common.AwsUtils;
import com.netflix.ice.common.TagGroup;
import com.netflix.ice.tag.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -37,7 +38,7 @@ public class TagGroupWriter {
private File file;

TagGroupWriter(String name) throws Exception {

name = Tag.toS3(name);
dbName = DB_PREFIX + name;
file = new File(config.localDir, dbName);
logger.info("creating TagGroupWriter for " + file);
Expand Down
18 changes: 18 additions & 0 deletions src/java/com/netflix/ice/tag/Tag.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ public int compareTo(Tag t) {
};

public final String name;
public final String s3Name;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this field used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, it has been a long week. Indeed their is some code that I have forgotten. Demuxing my large pull request from last year:-)

Tag(String name) {
this.name = name;
this.s3Name = Tag.toS3(name);
}

@Override
Expand All @@ -40,6 +42,22 @@ public boolean equals(Object o) {
return false;
}

/**
* Normalize a tagname suitable to be an S3 Filename
*/
public static String toS3(String name) {
name = name.replaceAll("/","--");
return name;
}

/**
* Normalize a tagname from an S3 Filename
*/
public static String fromS3(String name) {
name = name.replaceAll("--","/");
return name;
}

@Override
public String toString() {
return this.name;
Expand Down