Search in sources :

Example 1 with CompactionPlanner

use of org.apache.accumulo.core.spi.compaction.CompactionPlanner in project accumulo by apache.

the class CheckCompactionConfig method execute.

@Override
public void execute(String[] args) throws Exception {
    Opts opts = new Opts();
    opts.parseArgs(keyword(), args);
    if (opts.filePath == null) {
        throw new IllegalArgumentException("No properties file was given");
    }
    Path path = Path.of(opts.filePath);
    if (!path.toFile().exists())
        throw new FileNotFoundException("File at given path could not be found");
    AccumuloConfiguration config = SiteConfiguration.fromFile(path.toFile()).build();
    var servicesConfig = new CompactionServicesConfig(config, log::warn);
    ServiceEnvironment senv = createServiceEnvironment(config);
    Set<String> defaultServices = Set.of(DEFAULT, META, ROOT);
    if (servicesConfig.getPlanners().keySet().equals(defaultServices)) {
        log.warn("Only the default compaction services were created - {}", defaultServices);
        return;
    }
    for (var entry : servicesConfig.getPlanners().entrySet()) {
        String serviceId = entry.getKey();
        String plannerClassName = entry.getValue();
        log.info("Service id: {}, planner class:{}", serviceId, plannerClassName);
        Class<? extends CompactionPlanner> plannerClass = Class.forName(plannerClassName).asSubclass(CompactionPlanner.class);
        CompactionPlanner planner = plannerClass.getDeclaredConstructor().newInstance();
        var initParams = new CompactionPlannerInitParams(CompactionServiceId.of(serviceId), servicesConfig.getOptions().get(serviceId), senv);
        planner.init(initParams);
        initParams.getRequestedExecutors().forEach((execId, numThreads) -> log.info("Compaction service '{}' requested creation of thread pool '{}' with {} threads.", serviceId, execId, numThreads));
        initParams.getRequestedExternalExecutors().forEach(execId -> log.info("Compaction service '{}' requested with external execution queue '{}'", serviceId, execId));
    }
    log.info("Properties file has passed all checks.");
}
Also used : Path(java.nio.file.Path) CompactionServicesConfig(org.apache.accumulo.core.util.compaction.CompactionServicesConfig) FileNotFoundException(java.io.FileNotFoundException) ServiceEnvironment(org.apache.accumulo.core.spi.common.ServiceEnvironment) CompactionPlannerInitParams(org.apache.accumulo.core.util.compaction.CompactionPlannerInitParams) CompactionPlanner(org.apache.accumulo.core.spi.compaction.CompactionPlanner) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)1 Path (java.nio.file.Path)1 AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)1 ServiceEnvironment (org.apache.accumulo.core.spi.common.ServiceEnvironment)1 CompactionPlanner (org.apache.accumulo.core.spi.compaction.CompactionPlanner)1 CompactionPlannerInitParams (org.apache.accumulo.core.util.compaction.CompactionPlannerInitParams)1 CompactionServicesConfig (org.apache.accumulo.core.util.compaction.CompactionServicesConfig)1