Skip to content

Commit

Permalink
Merge pull request #773 from hawkular/fix_warnings_2
Browse files Browse the repository at this point in the history
Resolve a lot of warnings.
  • Loading branch information
John Sanda committed Apr 11, 2017
2 parents b96cd23 + 864892e commit 18bfaf0
Show file tree
Hide file tree
Showing 22 changed files with 51 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,12 @@ private void runOnAll() {
long end = now - q.getMetricsOffset().toMillis();
long start = end - q.getMetricsDuration().toMillis();
List<Percentile> percentiles = q.getMetricsPercentiles();
List<BucketPoint> result;

List<? extends BucketPoint> result;

if (isAvail) {
result = findMetricsByNameOrTags(trigger.getTenantId(), metrics, tags, AVAILABILITY)
result = findMetricsByNameOrTags(trigger.getTenantId(), metrics,
tags, AVAILABILITY)
.toList()
.flatMap(metricIds -> {
if (metricIds.size() != 1) {
Expand All @@ -362,6 +364,7 @@ private void runOnAll() {
.toBlocking()
.firstOrDefault(Collections.EMPTY_LIST);
}

if (result.size() != 1) {
throw new IllegalStateException(
"Failed to retrieve proper data " + result + " for query [%s]" + q.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ public void queryConstructorTest() {
}

q2 = new Query("qYesterday", "1d", q1);
@SuppressWarnings("unused")
ConditionExpression mc1 = new ConditionExpression(Arrays.asList(q1, q2), "5mn", EvalType.ALL,
"q(qNow,avg) > q(qYesterday,avg)");
assertFalse(q1.getName().equals(q2.getName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ private void startMetricsService() {
new MetricsInitializer(metricRegistry, metricsService, metricNameService).run();

if (Boolean.valueOf(metricsReportingEnabled)) {
@SuppressWarnings("resource")
DropWizardReporter reporter = new DropWizardReporter(metricRegistry, metricNameService, metricsService);
reporter.start(30, SECONDS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
import org.hawkular.metrics.model.param.TagNames;
import org.hawkular.metrics.model.param.Tags;
import org.hawkular.metrics.model.param.TimeRange;
import org.jboss.logging.Logger;
import org.jboss.resteasy.annotations.GZIP;

import io.swagger.annotations.Api;
Expand All @@ -99,8 +98,6 @@
@Logged
public class GaugeHandler extends MetricsServiceHandler implements IMetricsHandler<Double> {

private Logger logger = Logger.getLogger(GaugeHandler.class);

@POST
@Path("/")
@ApiOperation(value = "Create gauge metric.", notes = "Clients are not required to explicitly create "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ public void addMetricsData(

@POST
@Path("/stats/query")
@SuppressWarnings("unchecked")
public void findStats(@Suspended AsyncResponse asyncResponse, StatsQueryRequest query) {
try {
checkRequiredParams(query);
Expand Down Expand Up @@ -402,7 +401,7 @@ private Observable<Map<String, Map<String, List<? extends BucketPoint>>>> doStat
availabilityStats = Observable.from(query.getMetrics().get("availability"))
.flatMap(id -> metricsService.findAvailabilityStats(new MetricId<>(getTenant(), AVAILABILITY,
id), timeRange.getStart(), timeRange.getEnd(), bucketsConfig.getBuckets())
.map(bucketPoints -> new NamedBucketPoints(id, bucketPoints)))
.map(bucketPoints -> new NamedBucketPoints<>(id, bucketPoints)))
.collect(HashMap::new, (statsMap, namedBucketPoints) -> statsMap.put(namedBucketPoints.id,
namedBucketPoints.bucketPoints));
}
Expand All @@ -419,7 +418,7 @@ private Observable<Map<String, Map<String, List<? extends BucketPoint>>>> doStat
gauges = metricsService.findMetricsWithFilters(getTenant(), GAUGE, query.getTags()).cache();
gaugeStats = gauges.flatMap(gauge ->
metricsService.findGaugeStats(gauge.getMetricId(), bucketsConfig, percentiles)
.map(bucketPoints -> new NamedBucketPoints(gauge.getMetricId().getName(),
.map(bucketPoints -> new NamedBucketPoints<>(gauge.getMetricId().getName(),
bucketPoints)))
.collect(HashMap::new, (statsMap, namedBucketPoints) ->
statsMap.put(namedBucketPoints.id, namedBucketPoints.bucketPoints));
Expand Down Expand Up @@ -490,7 +489,6 @@ private void checkRequiredParams(StatsQueryRequest query) {
}
}

@SuppressWarnings("unchecked")
private Observable<Map<String, List<? extends BucketPoint>>> getCounterStatsFromTags(BucketConfig bucketsConfig,
List<Percentile> percentiles, String tags) {
Observable<Metric<Long>> counters = metricsService.findMetricsWithFilters(getTenant(), COUNTER, tags);
Expand All @@ -502,19 +500,17 @@ private Observable<Map<String, List<? extends BucketPoint>>> getCounterStatsFrom
statsMap.put(namedBucketPoints.id, namedBucketPoints.bucketPoints));
}

@SuppressWarnings("unchecked")
private Observable<Map<String, List<? extends BucketPoint>>> getGaugeStatsFromTags(BucketConfig bucketsConfig,
List<Percentile> percentiles, String tags) {
Observable<Metric<Double>> gauges = metricsService.findMetricsWithFilters(getTenant(), GAUGE, tags);
return gauges.flatMap(gauge ->
metricsService.findGaugeStats(gauge.getMetricId(), bucketsConfig, percentiles)
.map(bucketPoints -> new NamedBucketPoints(gauge.getMetricId().getName(),
.map(bucketPoints -> new NamedBucketPoints<>(gauge.getMetricId().getName(),
bucketPoints)))
.collect(HashMap::new, (statsMap, namedBucketPoints) ->
statsMap.put(namedBucketPoints.id, namedBucketPoints.bucketPoints));
}

@SuppressWarnings("unchecked")
private Observable<Map<String, List<? extends BucketPoint>>> getAvailabilityStatsFromTags(
BucketConfig bucketsConfig, String tags) {
Observable<Metric<AvailabilityType>> availabilities = metricsService.findMetricsWithFilters(getTenant(),
Expand All @@ -530,14 +526,13 @@ private Observable<Map<String, List<? extends BucketPoint>>> getAvailabilityStat
return availabilityStats;
}

@SuppressWarnings("unchecked")
private Observable<Map<String, List<? extends BucketPoint>>> getGaugeStats(StatsQueryRequest query,
BucketConfig bucketsConfig, List<Percentile> percentiles) {
Observable<Map<String, List<? extends BucketPoint>>> gaugeStats;
gaugeStats = Observable.from(query.getMetrics().get("gauge"))
.flatMap(id -> metricsService.findGaugeStats(new MetricId<>(getTenant(), GAUGE, id),
bucketsConfig, percentiles)
.map(bucketPoints -> new NamedBucketPoints(id, bucketPoints)))
.map(bucketPoints -> new NamedBucketPoints<>(id, bucketPoints)))
.collect(HashMap::new, (statsMap, namedBucketPoints) ->
statsMap.put(namedBucketPoints.id, namedBucketPoints.bucketPoints));
return gaugeStats;
Expand All @@ -559,14 +554,13 @@ private Observable<Map<String, List<? extends BucketPoint>>> getCounterStats(Obs
statsMap.put(namedBucketPoints.id, namedBucketPoints.bucketPoints));
}

@SuppressWarnings("unchecked")
private Observable<Map<String, List<? extends BucketPoint>>> getCounterStats(StatsQueryRequest query,
BucketConfig bucketsConfig, List<Percentile> percentiles) {
Observable<Map<String, List<? extends BucketPoint>>> counterStats;
counterStats = Observable.from(query.getMetrics().get("counter"))
.flatMap(id -> metricsService.findCounterStats(new MetricId<>(getTenant(), COUNTER, id),
bucketsConfig, percentiles)
.map(bucketPoints -> new NamedBucketPoints(id, bucketPoints)))
.map(bucketPoints -> new NamedBucketPoints<>(id, bucketPoints)))
.collect(HashMap::new, (statsMap, namedBucketPoints) -> statsMap.put(namedBucketPoints.id,
namedBucketPoints.bucketPoints));
return counterStats;
Expand Down
1 change: 0 additions & 1 deletion clients/common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.7</version>
<scope>provided</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 Red Hat, Inc. and/or its affiliates
* Copyright 2014-2017 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");
Expand All @@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.hawkular.openshift.auth;


Expand Down Expand Up @@ -56,6 +55,7 @@ public class OpenshiftAuthHandler implements HttpHandler {
private final BasicAuthenticator basicAuthenticator;

private final Pattern insecureEndpoints;
@SuppressWarnings("unused")
private final Pattern postQuery;

public OpenshiftAuthHandler(HttpHandler containerHandler, String componentName, String resourceName, Pattern insecureEndpoints, Pattern postQuery) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;

import org.hawkular.metrics.core.service.MetricsService;
Expand Down Expand Up @@ -98,7 +97,7 @@ public List<JobDetails> start() {
List<JobDetails> backgroundJobs = new ArrayList<>();

deleteTenant = new DeleteTenant(session, metricsService);
Map<JobDetails, Integer> deleteTenantAttempts = new ConcurrentHashMap<>();

// Use a simple retry policy to make sure tenant deletion does complete in the event of failure. For now
// we simply retry after 5 minutes. We can implement a more sophisticated strategy later on if need be.
Func2<JobDetails, Throwable, RetryPolicy> deleteTenantRetryPolicy = (details, throwable) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,22 @@ public interface DataAccess {

Observable<Row> findAllMetricsInData();

Observable<Integer> insertGaugeDatas(Observable<Metric<Double>> gauges, Function<MetricId, Integer> ttlFunc);
Observable<Integer> insertGaugeDatas(Observable<Metric<Double>> gauges,
Function<MetricId<Double>, Integer> ttlFunc);

Observable<Integer> insertGaugeData(Metric<Double> metric);

Observable<Integer> insertGaugeData(Metric<Double> metric, int ttl);

Observable<Integer> insertStringDatas(Observable<Metric<String>> strings, Function<MetricId, Integer>
ttlFetcher, int maxSize);
Observable<Integer> insertStringDatas(Observable<Metric<String>> strings,
Function<MetricId<String>, Integer> ttlFetcher, int maxSize);

Observable<Integer> insertStringData(Metric<String> metric, int maxSize);

Observable<Integer> insertStringData(Metric<String> metric, int ttl, int maxSize);

Observable<Integer> insertCounterDatas(Observable<Metric<Long>> counters, Function<MetricId, Integer>
ttlFetcher);
Observable<Integer> insertCounterDatas(Observable<Metric<Long>> counters,
Function<MetricId<Long>, Integer> ttlFetcher);

Observable<Integer> insertCounterData(Metric<Long> counter);

Expand Down Expand Up @@ -109,8 +110,8 @@ Observable<Row> findAvailabilityData(MetricId<AvailabilityType> id, long startTi

<T> Observable<ResultSet> deleteMetricFromMetricsIndex(MetricId<T> id);

Observable<Integer> insertAvailabilityDatas(Observable<Metric<AvailabilityType>> avail, Function<MetricId,
Integer> ttlFetcher);
Observable<Integer> insertAvailabilityDatas(Observable<Metric<AvailabilityType>> avail,
Function<MetricId<AvailabilityType>, Integer> ttlFetcher);

Observable<Integer> insertAvailabilityData(Metric<AvailabilityType> metric);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -732,9 +732,8 @@ private <T> Observable.Transformer<T, T> applyInsertRetryPolicy() {
}

@Override
public Observable<Integer> insertGaugeDatas(Observable<Metric<Double>> gauges, Function<MetricId, Integer>
ttlFetcher) {

public Observable<Integer> insertGaugeDatas(Observable<Metric<Double>> gauges,
Function<MetricId<Double>, Integer> ttlFetcher) {
return gauges
.flatMap(gauge -> {
int ttl = ttlFetcher.apply(gauge.getMetricId());
Expand Down Expand Up @@ -811,8 +810,8 @@ private Observable.Transformer<DataPoint<String>, BoundStatement> mapStringDatap
}

@Override
public Observable<Integer> insertStringDatas(Observable<Metric<String>> strings, Function<MetricId, Integer>
ttlFetcher, int maxSize) {
public Observable<Integer> insertStringDatas(Observable<Metric<String>> strings,
Function<MetricId<String>, Integer> ttlFetcher, int maxSize) {

return strings
.flatMap(string -> {
Expand Down Expand Up @@ -862,8 +861,8 @@ private Observable.Transformer<DataPoint<Long>, BoundStatement> mapCounterDatapo
}

@Override
public Observable<Integer> insertCounterDatas(Observable<Metric<Long>> counters, Function<MetricId, Integer>
ttlFetcher) {
public Observable<Integer> insertCounterDatas(Observable<Metric<Long>> counters,
Function<MetricId<Long>, Integer> ttlFetcher) {

return counters
.flatMap(counter -> {
Expand Down Expand Up @@ -1097,7 +1096,7 @@ private Observable.Transformer<DataPoint<AvailabilityType>, BoundStatement> mapA

@Override
public Observable<Integer> insertAvailabilityDatas(Observable<Metric<AvailabilityType>> avail,
Function<MetricId, Integer> ttlFetcher) {
Function<MetricId<AvailabilityType>, Integer> ttlFetcher) {
return avail
.flatMap(a -> {
int ttl = ttlFetcher.apply(a.getMetricId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ public <T> Observable<Metric<T>> findMetrics(String tenantId, MetricType<T> metr
return setFromMetricsIndex.concatWith(setFromData).distinct(m -> m.getMetricId());
}

@SuppressWarnings("unchecked")
@Override
public <T> Observable<Metric<T>> findMetricsWithFilters(String tenantId, MetricType<T> metricType, String tags) {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 Red Hat, Inc. and/or its affiliates
* Copyright 2014-2017 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");
Expand Down Expand Up @@ -38,8 +38,11 @@ public enum Compressor {
GORILLA((byte) 0x10, GorillaSettings.class);

private byte value;

@SuppressWarnings("rawtypes")
private Class enumClass;

@SuppressWarnings("rawtypes")
Compressor(byte value, Class enumClass) {
this.value = value;
this.enumClass = enumClass;
Expand All @@ -49,6 +52,7 @@ public byte getByteValue() {
return this.value;
}

@SuppressWarnings("rawtypes")
public <E extends Enum<E> & CompressorSetting> Class getSettingsClass() {
return enumClass;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ public void testCompressJob() throws Exception {
assertNull(tags);
}

@SuppressWarnings("unchecked")
private <T> void testCompressResults(MetricType<T> type, Metric<T> metric, DateTime start) throws
Exception {
if (metric.getDataPoints() != null && !metric.getDataPoints().isEmpty()) {
Expand All @@ -207,7 +206,7 @@ private <T> void testCompressResults(MetricType<T> type, Metric<T> metric, DateT
long startSlice = DateTimeService.getTimeSlice(start.getMillis(), Duration.standardHours(2));
long endSlice = DateTimeService.getTimeSlice(jobScheduler.now(), Duration.standardHours(2));

DataPointDecompressTransformer decompressor = new DataPointDecompressTransformer(type, Order.ASC, 0, start
DataPointDecompressTransformer<T> decompressor = new DataPointDecompressTransformer<>(type, Order.ASC, 0, start
.getMillis(), start.plusMinutes(30).getMillis());

Observable<DataPoint<T>> dataPoints = dataAccess.findCompressedData(metric.getMetricId(), startSlice, endSlice,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ public void deleteTenantTwiceConcurrently() throws Exception {
@Test
public void deleteNonexistentTenant() throws Exception {
String tenantId = nextTenantId();
DateTime start = new DateTime(jobScheduler.now());

JobDetails details = jobsService.submitDeleteTenantJob(tenantId, jobName).toBlocking().value();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 Red Hat, Inc. and/or its affiliates
* Copyright 2014-2017 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");
Expand Down Expand Up @@ -199,6 +199,7 @@ public void findAllMetricsPartitionKeys() throws Exception {
.flatMap(m -> dataAccess.insertGaugeData(m, DEFAULT_TTL))
.toBlocking().lastOrDefault(null);

@SuppressWarnings("unchecked")
List<Metric<Double>> metrics = toList(dataAccess.findAllMetricsInData()
.compose(new MetricFromFullDataRowTransformer(Duration.standardDays(7).toStandardSeconds().getSeconds
()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ public Observable<Row> findAllMetricsInData() {
}

@Override
public Observable<Integer> insertGaugeDatas(Observable<Metric<Double>> gauges, Function<MetricId,
Integer> ttlFunction) {
public Observable<Integer> insertGaugeDatas(Observable<Metric<Double>> gauges,
Function<MetricId<Double>, Integer> ttlFunction) {
return delegate.insertGaugeDatas(gauges, ttlFunction);
}

Expand All @@ -131,7 +131,7 @@ public Observable<Integer> insertGaugeData(Metric<Double> gauge, int ttl) {

@Override
public Observable<Integer> insertStringDatas(Observable<Metric<String>> strings,
Function<MetricId, Integer> ttlFetcher, int maxSize) {
Function<MetricId<String>, Integer> ttlFetcher, int maxSize) {
return delegate.insertStringDatas(strings, ttlFetcher, maxSize);
}

Expand Down Expand Up @@ -174,7 +174,7 @@ public Observable<Integer> insertStringData(Metric<String> metric, int ttl, int

@Override
public Observable<Integer> insertCounterDatas(Observable<Metric<Long>> counters,
Function<MetricId, Integer> ttlFetcher) {
Function<MetricId<Long>, Integer> ttlFetcher) {
return delegate.insertCounterDatas(counters, ttlFetcher);
}

Expand Down Expand Up @@ -207,7 +207,7 @@ public <T> Observable<ResultSet> deleteMetricFromMetricsIndex(MetricId<T> id) {

@Override
public Observable<Integer> insertAvailabilityDatas(Observable<Metric<AvailabilityType>> avail,
Function<MetricId, Integer> ttlFetcher) {
Function<MetricId<AvailabilityType>, Integer> ttlFetcher) {
return delegate.insertAvailabilityDatas(avail, ttlFetcher);
}

Expand Down

0 comments on commit 18bfaf0

Please sign in to comment.