Search in sources :

Example 1 with CompactionPlannerInitParams

use of org.apache.accumulo.core.util.compaction.CompactionPlannerInitParams 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)

Example 2 with CompactionPlannerInitParams

use of org.apache.accumulo.core.util.compaction.CompactionPlannerInitParams in project accumulo by apache.

the class CompactionService method configurationChanged.

public void configurationChanged(String plannerClassName, Long maxRate, Map<String, String> plannerOptions) {
    Preconditions.checkArgument(maxRate >= 0);
    var old = this.rateLimit.getAndSet(maxRate);
    if (old != maxRate)
        log.debug("Updated compaction service id:{} rate limit:{}", myId, maxRate);
    if (this.plannerClassName.equals(plannerClassName) && this.plannerOpts.equals(plannerOptions))
        return;
    var initParams = new CompactionPlannerInitParams(myId, plannerOptions, new ServiceEnvironmentImpl(context));
    var tmpPlanner = createPlanner(plannerClassName);
    tmpPlanner.init(initParams);
    Map<CompactionExecutorId, CompactionExecutor> tmpExecutors = new HashMap<>();
    initParams.getRequestedExecutors().forEach((ceid, numThreads) -> {
        InternalCompactionExecutor executor = (InternalCompactionExecutor) executors.get(ceid);
        if (executor == null) {
            executor = new InternalCompactionExecutor(ceid, numThreads, ceMetrics, readLimiter, writeLimiter);
        } else {
            executor.setThreads(numThreads);
        }
        tmpExecutors.put(ceid, executor);
    });
    initParams.getRequestedExternalExecutors().forEach(ceid -> {
        ExternalCompactionExecutor executor = (ExternalCompactionExecutor) executors.get(ceid);
        if (executor == null) {
            executor = externExecutorSupplier.apply(ceid);
        }
        tmpExecutors.put(ceid, executor);
    });
    Sets.difference(executors.keySet(), tmpExecutors.keySet()).forEach(ceid -> {
        executors.get(ceid).stop();
    });
    this.plannerClassName = plannerClassName;
    this.plannerOpts = plannerOptions;
    this.executors = Map.copyOf(tmpExecutors);
    this.planner = tmpPlanner;
    log.debug("Updated compaction service id:{} planner:{} options:{}", myId, plannerClassName, plannerOptions);
}
Also used : ServiceEnvironmentImpl(org.apache.accumulo.server.ServiceEnvironmentImpl) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CompactionPlannerInitParams(org.apache.accumulo.core.util.compaction.CompactionPlannerInitParams) CompactionExecutorId(org.apache.accumulo.core.spi.compaction.CompactionExecutorId)

Aggregations

CompactionPlannerInitParams (org.apache.accumulo.core.util.compaction.CompactionPlannerInitParams)2 FileNotFoundException (java.io.FileNotFoundException)1 Path (java.nio.file.Path)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)1 ServiceEnvironment (org.apache.accumulo.core.spi.common.ServiceEnvironment)1 CompactionExecutorId (org.apache.accumulo.core.spi.compaction.CompactionExecutorId)1 CompactionPlanner (org.apache.accumulo.core.spi.compaction.CompactionPlanner)1 CompactionServicesConfig (org.apache.accumulo.core.util.compaction.CompactionServicesConfig)1 ServiceEnvironmentImpl (org.apache.accumulo.server.ServiceEnvironmentImpl)1