Skip to content

Commit

Permalink
[HWKMETRIC-207] clean up MetricsServiceImpl.createTenant method
Browse files Browse the repository at this point in the history
  • Loading branch information
John Sanda committed Aug 8, 2015
1 parent 38ff28c commit 55f9af6
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 432 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import com.google.common.base.Objects;

/**
* The retention is stored in days.
*
* @author John Sanda
*/
public class Retention {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
*/
package org.hawkular.metrics.core.api;

import java.util.ArrayList;
import java.util.List;
import java.util.Collections;
import java.util.Map;

import com.google.common.base.Objects;
import com.google.common.collect.ImmutableMap;

/**
* Hawkular Metrics provides multi-tenancy support. This means that all data is implicitly partitioned by tenant. Tags,
Expand All @@ -32,51 +33,25 @@ public class Tenant {

private String id;

// @JsonInclude(Include.NON_EMPTY)
private List<AggregationTemplate> aggregationTemplates = new ArrayList<>();

// @JsonIgnore
private RetentionSettings retentionSettings = new RetentionSettings();
private Map<MetricType, Integer> retentionSettings = Collections.emptyMap();

public Tenant(String id) {
this.id = id;
}

public String getId() {
return id;
}

/**
* The configured {@link org.hawkular.metrics.core.api.AggregationTemplate aggregation templates} for the tenant
*/
public List<AggregationTemplate> getAggregationTemplates() {
return aggregationTemplates;
public Tenant(String id, Map<MetricType, Integer> retentionSettings) {
this.id = id;
this.retentionSettings = ImmutableMap.copyOf(retentionSettings);
}

public Tenant addAggregationTemplate(AggregationTemplate template) {
aggregationTemplates.add(template);
return this;
public String getId() {
return id;
}

/**
* The {@link org.hawkular.metrics.core.api.RetentionSettings data retention settings} for both
* raw and aggregated data of all metric types
*/
public RetentionSettings getRetentionSettings() {
public Map<MetricType, Integer> getRetentionSettings() {
return retentionSettings;
}

public Tenant setRetention(MetricType type, int hours) {
retentionSettings.put(type, hours);
return this;
}

public Tenant setRetention(MetricType type, Interval interval, int hours) {
retentionSettings.put(type, interval, hours);
return this;
}


@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand All @@ -98,7 +73,6 @@ public int hashCode() {
public String toString() {
return Objects.toStringHelper(getClass())
.add("id", id)
.add("aggregationTemplates", aggregationTemplates)
.add("retentionSettings", retentionSettings)
.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,15 @@
import java.util.Map;
import java.util.Set;

import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.ResultSetFuture;
import org.hawkular.metrics.core.api.AvailabilityType;
import org.hawkular.metrics.core.api.DataPoint;
import org.hawkular.metrics.core.api.Interval;
import org.hawkular.metrics.core.api.Metric;
import org.hawkular.metrics.core.api.MetricId;
import org.hawkular.metrics.core.api.MetricType;
import org.hawkular.metrics.core.api.Retention;
import org.hawkular.metrics.core.api.Tenant;

import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.ResultSetFuture;

import rx.Observable;

/**
Expand Down Expand Up @@ -109,7 +106,7 @@ Observable<ResultSet> insertAvailabilityTag(String tag, String tagValue,

ResultSetFuture findDataRetentions(String tenantId, MetricType type);

ResultSetFuture updateRetentionsIndex(String tenantId, MetricType type, Set<Retention> retentions);
Observable<ResultSet> updateRetentionsIndex(String tenantId, MetricType type, Map<String, Integer> retentions);

ResultSetFuture updateRetentionsIndex(Metric metric);

Expand Down

0 comments on commit 55f9af6

Please sign in to comment.