Skip to content

Commit

Permalink
[HWKMETRICS-768] remove DeleteExpiredMetrics job and related code (#942)
Browse files Browse the repository at this point in the history
* [HWKMETRICS-768] remove DeleteExpiredMetrics job and related code ( backport of HWKMETRICS-765)

Remove DeleteExpiredMetrics job and related code

Remove more code related to metrics_expiration_idx

Unscheduled delete expired metrics job and remove config.

I have also disabled a test in MixedMetricsITest and DataAccessItest::testFindAllDataFromBucket which fails inconsistently.

* Fix MixedMetricsITest and MetricsServiceImpl.deleteMetric() execution order
  • Loading branch information
rubenvp8510 authored and John Sanda committed Apr 13, 2018
1 parent d9aa1b2 commit 418076c
Show file tree
Hide file tree
Showing 28 changed files with 147 additions and 743 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2017 Red Hat, Inc. and/or its affiliates
* Copyright 2014-2018 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 @@ -43,9 +43,6 @@
import static org.hawkular.metrics.api.jaxrs.config.ConfigurationKey.INGEST_MAX_RETRIES;
import static org.hawkular.metrics.api.jaxrs.config.ConfigurationKey.INGEST_MAX_RETRY_DELAY;
import static org.hawkular.metrics.api.jaxrs.config.ConfigurationKey.JMX_REPORTING_ENABLED;
import static org.hawkular.metrics.api.jaxrs.config.ConfigurationKey.METRICS_EXPIRATION_DELAY;
import static org.hawkular.metrics.api.jaxrs.config.ConfigurationKey.METRICS_EXPIRATION_JOB_ENABLED;
import static org.hawkular.metrics.api.jaxrs.config.ConfigurationKey.METRICS_EXPIRATION_JOB_FREQUENCY;
import static org.hawkular.metrics.api.jaxrs.config.ConfigurationKey.METRICS_REPORTING_COLLECTION_INTERVAL;
import static org.hawkular.metrics.api.jaxrs.config.ConfigurationKey.METRICS_REPORTING_ENABLED;
import static org.hawkular.metrics.api.jaxrs.config.ConfigurationKey.METRICS_REPORTING_HOSTNAME;
Expand Down Expand Up @@ -296,21 +293,6 @@ public enum State {
@ConfigurationProperty(METRICS_REPORTING_COLLECTION_INTERVAL)
private String collectionIntervalConfig;

@Inject
@Configurable
@ConfigurationProperty(METRICS_EXPIRATION_DELAY)
private String metricExpirationDelay;

@Inject
@Configurable
@ConfigurationProperty(METRICS_EXPIRATION_JOB_FREQUENCY)
private String metricsExpirationJobFrequency;

@Inject
@Configurable
@ConfigurationProperty(METRICS_EXPIRATION_JOB_ENABLED)
private String metricsExpirationJobEnabled;

@Inject
@ServiceReady
Event<ServiceReadyEvent> metricsServiceReady;
Expand Down Expand Up @@ -718,10 +700,7 @@ private boolean parseBooleanConfig(String value, ConfigurationKey configKey) {
private void initJobsService() {

RxSession rxSession = new RxSessionImpl(session);
jobsService = new JobsServiceImpl(
parseIntConfig(metricExpirationDelay, METRICS_EXPIRATION_DELAY),
parseIntConfig(metricsExpirationJobFrequency, METRICS_EXPIRATION_JOB_FREQUENCY),
parseBooleanConfig(metricsExpirationJobEnabled, METRICS_EXPIRATION_JOB_ENABLED));
jobsService = new JobsServiceImpl();
jobsService.setMetricsService(metricsService);
jobsService.setConfigurationService(configurationService);
jobsService.setSession(rxSession);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2017 Red Hat, Inc. and/or its affiliates
* Copyright 2014-2018 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 @@ -72,13 +72,6 @@ public enum ConfigurationKey {
METRICS_REPORTING_COLLECTION_INTERVAL("hawkular.metrics.reporting.collection-interval", "300",
"METRICS_REPORTING_COLLECTION_INTERVAL", false),

//Metric expiration job configuration
METRICS_EXPIRATION_DELAY("hawkular.metrics.expiration.delay", "1", "METRICS_EXPIRATION_DELAY", false),
METRICS_EXPIRATION_JOB_FREQUENCY("hawkular.metrics.jobs.expiration.frequency", "7",
"METRICS_EXPIRATION_JOB_FREQUENCY", false),
METRICS_EXPIRATION_JOB_ENABLED("hawkular.metrics.jobs.expiration.enabled", "true",
"METRICS_EXPIRATION_JOB_ENABLED", false),

// Request logging properties
// Useful for debugging
REQUEST_LOGGING_LEVEL("hawkular.metrics.request.logging.level", null, "REQUEST_LOGGING_LEVEL", false),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2017 Red Hat, Inc. and/or its affiliates
* Copyright 2014-2018 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 @@ -24,6 +24,7 @@
import com.datastax.driver.core.ConsistencyLevel;
import com.datastax.driver.core.PreparedStatement;

import rx.Completable;
import rx.Observable;
import rx.Scheduler;

Expand All @@ -42,6 +43,8 @@ public class ConfigurationService {

private PreparedStatement deleteConfigurationValue;

private PreparedStatement deleteConfiguration;

// TODO make async
// I could have just as easily passed the session as a constructor arg. I am doing it in the init method because
// eventually I would like service initialization async.
Expand All @@ -62,6 +65,10 @@ public void init(RxSession session) {
deleteConfigurationValue = session.getSession().prepare(
"DELETE FROM sys_config WHERE config_id =? and name = ?")
.setConsistencyLevel(ConsistencyLevel.LOCAL_QUORUM);

deleteConfiguration = session.getSession().prepare(
"DELETE FROM sys_config WHERE config_id = ?")
.setConsistencyLevel(ConsistencyLevel.LOCAL_QUORUM);
}

public Observable<Configuration> load(String id) {
Expand Down Expand Up @@ -97,7 +104,11 @@ public Observable<Void> save(String configId, String name, String value, Schedul
return session.execute(updateConfigurationValue.bind(configId, name, value), scheduler).map(resultSet -> null);
}

public Observable<Void> delete(String configId, String name) {
return session.execute(deleteConfigurationValue.bind(configId, name)).map(resultSet -> null);
public Completable delete(String configId, String name) {
return session.execute(deleteConfigurationValue.bind(configId, name)).toCompletable();
}

public Completable delete(String configId) {
return session.execute(deleteConfiguration.bind(configId)).toCompletable();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2017 Red Hat, Inc. and/or its affiliates
* Copyright 2014-2018 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 @@ -24,7 +24,6 @@

import org.hawkular.metrics.core.service.MetricsService;
import org.hawkular.metrics.datetime.DateTimeService;
import org.hawkular.metrics.model.Metric;
import org.hawkular.metrics.model.MetricId;
import org.hawkular.metrics.scheduler.api.JobDetails;
import org.hawkular.metrics.scheduler.api.RepeatingTrigger;
Expand All @@ -41,7 +40,6 @@
import rx.Completable;
import rx.Observable;
import rx.functions.Func1;
import rx.subjects.PublishSubject;

/**
* @author Michael Burman
Expand Down Expand Up @@ -124,25 +122,11 @@ public Completable call(JobDetails jobDetails) {
Observable<? extends MetricId<?>> metricIds = metricsService.findAllMetricIdentifiers()
.filter(m -> (m.getType() == GAUGE || m.getType() == COUNTER || m.getType() == AVAILABILITY));

PublishSubject<Metric<?>> subject = PublishSubject.create();
subject.subscribe(metric -> {
try {
this.metricsService.updateMetricExpiration(metric);
} catch (Exception e) {
logger.error("Could not update the metric expiration index for metric " + metric.getId()
+ " of tenant " + metric.getTenantId());
}
});

// Fetch all partition keys and compress the previous timeSlice
// TODO Optimization - new worker per token - use parallelism in Cassandra (with configured parallelism)
return metricsService.compressBlock(metricIds, startOfSlice, endOfSlice, pageSize, subject)
.doOnError(t -> {
subject.onCompleted();
logger.warn("Failed to compress data", t);
})
return metricsService.compressBlock(metricIds, startOfSlice, endOfSlice, pageSize)
.doOnError(t -> logger.warn("Failed to compress data", t))
.doOnCompleted(() -> {
subject.onCompleted();
stopwatch.stop();
logger.info("Finished compressing data in " + stopwatch.elapsed(TimeUnit.MILLISECONDS) +
" ms");
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2017 Red Hat, Inc. and/or its affiliates
* Copyright 2014-2018 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 @@ -33,5 +33,4 @@ public interface JobsService {

Single<? extends JobDetails> submitDeleteTenantJob(String tenantId, String jobName);

Single<? extends JobDetails> submitDeleteExpiredMetricsJob(long expiration, String jobName);
}

0 comments on commit 418076c

Please sign in to comment.