Log errors from single-shot account crawlers rather than printing them to stderr
This commit is contained in:
parent
540550d72a
commit
62e02a49df
|
@ -6,10 +6,13 @@
|
|||
package org.whispersystems.textsecuregcm.workers;
|
||||
|
||||
import io.dropwizard.Application;
|
||||
import io.dropwizard.cli.Cli;
|
||||
import io.dropwizard.cli.EnvironmentCommand;
|
||||
import io.dropwizard.setup.Environment;
|
||||
import net.sourceforge.argparse4j.inf.Namespace;
|
||||
import net.sourceforge.argparse4j.inf.Subparser;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.whispersystems.textsecuregcm.WhisperServerConfiguration;
|
||||
import org.whispersystems.textsecuregcm.metrics.MetricsUtil;
|
||||
import org.whispersystems.textsecuregcm.storage.Account;
|
||||
|
@ -23,6 +26,8 @@ public abstract class AbstractSinglePassCrawlAccountsCommand extends Environment
|
|||
|
||||
private CommandDependencies commandDependencies;
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private static final String SEGMENT_COUNT = "segments";
|
||||
|
||||
public AbstractSinglePassCrawlAccountsCommand(final String name, final String description) {
|
||||
|
@ -59,8 +64,18 @@ public abstract class AbstractSinglePassCrawlAccountsCommand extends Environment
|
|||
commandDependencies = CommandDependencies.build(getName(), environment, configuration);
|
||||
|
||||
final int segments = Objects.requireNonNull(namespace.getInt(SEGMENT_COUNT));
|
||||
|
||||
logger.info("Crawling accounts with {} segments and {} processors",
|
||||
segments,
|
||||
Runtime.getRuntime().availableProcessors());
|
||||
|
||||
crawlAccounts(commandDependencies.accountsManager().streamAllFromDynamo(segments, Schedulers.parallel()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(final Cli cli, final Namespace namespace, final Throwable throwable) {
|
||||
logger.error("Unhandled error", throwable);
|
||||
}
|
||||
|
||||
protected abstract void crawlAccounts(final ParallelFlux<Account> accounts);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue