Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #289 from burmanm/hwkmetrics-180
[HWKMETRICS-180] findMetricsWithTags supports now MatchType (ANY / ALL)
- Loading branch information
Showing
12 changed files
with
324 additions
and
50 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
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
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); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...pl/src/main/java/org/hawkular/metrics/core/impl/transformers/TagsIndexRowTransformer.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,51 @@ | ||
/* | ||
* 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.Row; | ||
import org.hawkular.metrics.core.api.Interval; | ||
import org.hawkular.metrics.core.api.MetricId; | ||
import org.hawkular.metrics.core.api.MetricType; | ||
import rx.Observable; | ||
|
||
/** | ||
* Transforms ResultSets's Rows from metrics_tags_idx to a MetricId. Requires the following order on select: | ||
* type, metric, interval | ||
* | ||
* @author Michael Burman | ||
*/ | ||
public class TagsIndexRowTransformer implements Observable.Transformer<Row, MetricId> { | ||
|
||
private MetricType type; | ||
private String tenantId; | ||
|
||
public TagsIndexRowTransformer(String tenantId, MetricType type) { | ||
this.type = type; | ||
this.tenantId = tenantId; | ||
} | ||
|
||
@Override | ||
public Observable<MetricId> call(Observable<Row> 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 MetricId(tenantId, MetricType.fromCode(r.getInt(0)), 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.