-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[HWKMETRICS-180] findMetricsWithTags supports now MatchType (ANY / ALL)
[HWKMETRICS-180] Add tagFiltering query language that allows more complex querying capabilities against tags in the metric definition table
- Loading branch information
Michael Burman
committed
Jul 30, 2015
1 parent
531e090
commit 9c13bbb
Showing
11 changed files
with
306 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
core/metrics-core-impl/src/main/java/org/hawkular/metrics/core/impl/tags/MetricIndex.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2014-2015 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.hawkular.metrics.core.impl.tags; | ||
|
||
import org.hawkular.metrics.core.api.MetricId; | ||
import org.hawkular.metrics.core.api.MetricType; | ||
|
||
/** | ||
* Represents required information from MetricIndex to transform later on to Metric. | ||
* | ||
* HWKMETRICS-114 might render this obsolete | ||
* | ||
* @author Michael Burman | ||
*/ | ||
public class MetricIndex { | ||
private final MetricType type; | ||
private final MetricId id; | ||
|
||
public MetricIndex(MetricType type, MetricId id) { | ||
this.type = type; | ||
this.id = id; | ||
} | ||
|
||
public MetricType getType() { | ||
return type; | ||
} | ||
|
||
public MetricId getId() { | ||
return id; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if(obj instanceof MetricIndex) { | ||
MetricIndex i = (MetricIndex) obj; | ||
return i.getId().getName().equals(this.getId().getName()) | ||
&& i.getType().equals(this.getType()); | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return this.getId().getName().hashCode() + this.getType().hashCode(); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...impl/src/main/java/org/hawkular/metrics/core/impl/transformers/ItemsToSetTransformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2014-2015 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.hawkular.metrics.core.impl.transformers; | ||
|
||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
import rx.Observable; | ||
import rx.functions.Func1; | ||
|
||
/** | ||
* RxJava Composer, transforms emitted items to a Set of items | ||
* | ||
* @author Michael Burman | ||
*/ | ||
public class ItemsToSetTransformer<T> implements Observable.Transformer<T, Set<T>> { | ||
|
||
@Override | ||
public Observable<Set<T>> call(Observable<T> metricIndexObservable) { | ||
return metricIndexObservable | ||
.toList() | ||
.switchIfEmpty(Observable.from(new HashSet<>())) | ||
.map((Func1<List<T>, HashSet<T>>) HashSet::new); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
.../main/java/org/hawkular/metrics/core/impl/transformers/TagsIndexResultSetTransformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright 2014-2015 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.hawkular.metrics.core.impl.transformers; | ||
|
||
import com.datastax.driver.core.ResultSet; | ||
import org.hawkular.metrics.core.api.Interval; | ||
import org.hawkular.metrics.core.api.MetricId; | ||
import org.hawkular.metrics.core.api.MetricType; | ||
import org.hawkular.metrics.core.impl.tags.MetricIndex; | ||
import rx.Observable; | ||
|
||
/** | ||
* Transforms ResultSets from metrics_tags_idx to a MetricIndex. Requires the following order on select: | ||
* type, metric, interval | ||
* | ||
* HWKMETRICS-114 might require changes to this | ||
* | ||
* @author Michael Burman | ||
*/ | ||
public class TagsIndexResultSetTransformer implements Observable.Transformer<ResultSet, MetricIndex> { | ||
|
||
private MetricType type; | ||
|
||
public TagsIndexResultSetTransformer(MetricType type) { | ||
this.type = type; | ||
} | ||
|
||
@Override | ||
public Observable<MetricIndex> call(Observable<ResultSet> resultSetObservable) { | ||
return resultSetObservable | ||
.flatMap(Observable::from) | ||
.filter(r -> (type == null | ||
&& MetricType.userTypes().contains(MetricType.fromCode(r.getInt(0)))) | ||
|| MetricType.fromCode(r.getInt(0)) == type) | ||
.map(r -> new MetricIndex(MetricType.fromCode(r.getInt(0)), new MetricId(r.getString | ||
(1), Interval.parse(r.getString(2))))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.