Search in sources :

Example 1 with DispatchParameters

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

the class CompactableImpl method getConfiguredService.

@Override
public CompactionServiceId getConfiguredService(CompactionKind kind) {
    Map<String, String> debugHints = null;
    try {
        var dispatcher = tablet.getTableConfiguration().getCompactionDispatcher();
        Map<String, String> tmpHints = Map.of();
        if (kind == CompactionKind.USER) {
            synchronized (this) {
                if (fileMgr.getSelectionStatus() != FileSelectionStatus.NOT_ACTIVE && fileMgr.getSelectionStatus() != FileSelectionStatus.CANCELED && fileMgr.getSelectionKind() == CompactionKind.USER) {
                    tmpHints = compactionConfig.getExecutionHints();
                }
            }
        }
        var hints = tmpHints;
        debugHints = hints;
        var dispatch = dispatcher.dispatch(new DispatchParameters() {

            private final ServiceEnvironment senv = new ServiceEnvironmentImpl(tablet.getContext());

            @Override
            public ServiceEnvironment getServiceEnv() {
                return senv;
            }

            @Override
            public Map<String, String> getExecutionHints() {
                return hints;
            }

            @Override
            public CompactionKind getCompactionKind() {
                return kind;
            }

            @Override
            public CompactionServices getCompactionServices() {
                return manager.getServices();
            }
        });
        return dispatch.getService();
    } catch (RuntimeException e) {
        log.error("Failed to dispatch compaction {} kind:{} hints:{}, falling back to {} service.", getExtent(), kind, debugHints, CompactionServicesConfig.DEFAULT_SERVICE, e);
        return CompactionServicesConfig.DEFAULT_SERVICE;
    }
}
Also used : ServiceEnvironment(org.apache.accumulo.core.spi.common.ServiceEnvironment) CompactionKind(org.apache.accumulo.core.spi.compaction.CompactionKind) ServiceEnvironmentImpl(org.apache.accumulo.server.ServiceEnvironmentImpl) DispatchParameters(org.apache.accumulo.core.spi.compaction.CompactionDispatcher.DispatchParameters) CompactionServices(org.apache.accumulo.core.spi.compaction.CompactionServices) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SortedMap(java.util.SortedMap) HashMap(java.util.HashMap)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ServiceEnvironment (org.apache.accumulo.core.spi.common.ServiceEnvironment)1 DispatchParameters (org.apache.accumulo.core.spi.compaction.CompactionDispatcher.DispatchParameters)1 CompactionKind (org.apache.accumulo.core.spi.compaction.CompactionKind)1 CompactionServices (org.apache.accumulo.core.spi.compaction.CompactionServices)1 ServiceEnvironmentImpl (org.apache.accumulo.server.ServiceEnvironmentImpl)1