Record the number of deletable accounts per crawled chunk.
This commit is contained in:
parent
39c09733d3
commit
8e1975efe4
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.whispersystems.textsecuregcm.storage;
|
package org.whispersystems.textsecuregcm.storage;
|
||||||
|
|
||||||
|
import com.codahale.metrics.Histogram;
|
||||||
import com.codahale.metrics.Meter;
|
import com.codahale.metrics.Meter;
|
||||||
import com.codahale.metrics.MetricRegistry;
|
import com.codahale.metrics.MetricRegistry;
|
||||||
import com.codahale.metrics.SharedMetricRegistries;
|
import com.codahale.metrics.SharedMetricRegistries;
|
||||||
|
@ -34,6 +35,7 @@ public class AccountCleaner extends AccountDatabaseCrawlerListener {
|
||||||
|
|
||||||
private static final MetricRegistry metricRegistry = SharedMetricRegistries.getOrCreate(Constants.METRICS_NAME);
|
private static final MetricRegistry metricRegistry = SharedMetricRegistries.getOrCreate(Constants.METRICS_NAME);
|
||||||
private static final Meter expiredAccountsMeter = metricRegistry.meter(name(AccountCleaner.class, "expiredAccounts"));
|
private static final Meter expiredAccountsMeter = metricRegistry.meter(name(AccountCleaner.class, "expiredAccounts"));
|
||||||
|
private static final Histogram deletableAccountHistogram = metricRegistry.histogram(name(AccountCleaner.class, "deletableAccountsPerChunk"));
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public static final int MAX_ACCOUNT_UPDATES_PER_CHUNK = 40;
|
public static final int MAX_ACCOUNT_UPDATES_PER_CHUNK = 40;
|
||||||
|
@ -55,7 +57,13 @@ public class AccountCleaner extends AccountDatabaseCrawlerListener {
|
||||||
@Override
|
@Override
|
||||||
protected void onCrawlChunk(Optional<UUID> fromUuid, List<Account> chunkAccounts) {
|
protected void onCrawlChunk(Optional<UUID> fromUuid, List<Account> chunkAccounts) {
|
||||||
int accountUpdateCount = 0;
|
int accountUpdateCount = 0;
|
||||||
|
int deletableAccountCount = 0;
|
||||||
|
|
||||||
for (Account account : chunkAccounts) {
|
for (Account account : chunkAccounts) {
|
||||||
|
if (isExpired(account)) {
|
||||||
|
deletableAccountCount++;
|
||||||
|
}
|
||||||
|
|
||||||
if (needsExplicitRemoval(account)) {
|
if (needsExplicitRemoval(account)) {
|
||||||
expiredAccountsMeter.mark();
|
expiredAccountsMeter.mark();
|
||||||
|
|
||||||
|
@ -65,6 +73,8 @@ public class AccountCleaner extends AccountDatabaseCrawlerListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deletableAccountHistogram.update(deletableAccountCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean needsExplicitRemoval(Account account) {
|
private boolean needsExplicitRemoval(Account account) {
|
||||||
|
|
Loading…
Reference in New Issue