dremio RuleBasedEngineSelector 简单介绍
dremio 提供了一个空的默认RuleBasedEngineSelector 实现,主要实现基于规则的引擎选择
接口定义以及默认空实现
public interface RuleBasedEngineSelector {
public String resolveAndUpdateEngine(ResourceSchedulingContext queryContext);
/**
* NO_OP implementation
*/
public static final RuleBasedEngineSelector NO_OP = new RuleBasedEngineSelector() {
@Override
public String resolveAndUpdateEngine(ResourceSchedulingContext queryContext) {
// 返回为空,不做操作
return null;
}
};
}
使用此服务的地方
SabotNode(测试了不包含ui 的执行框架),ForemenWorkManager(foreman 管理的),AttemptManager(管理所有fragement)
主要使用的还是SabotNode 以及AttemptManager
AttemptManager 对于RuleBasedEngineSelector使用的处理(主要是将查询的规则附加到)
String ruleSetEngine = ruleBasedEngineSelector.resolveAndUpdateEngine(queryContext);
ResourceSchedulingProperties resourceSchedulingProperties = new ResourceSchedulingProperties();
resourceSchedulingProperties.setRoutingEngine(queryContext.getSession().getRoutingEngine());
resourceSchedulingProperties.setRuleSetEngine(ruleSetEngine);
final GroupResourceInformation groupResourceInformation =
maestroService.getGroupResourceInformation(queryContext.getOptions(), resourceSchedulingProperties);
queryContext.setGroupResourceInformation(groupResourceInformation);
对于具体的使用是由BasicResourceAllocator进行具体的资源分配处理,但是很不好的是官方的实现没有直接使用此功能
反而使用的是基于队列的处理
参考代码
public ResourceSchedulingResult allocate(final ResourceSchedulingContext queryContext,
final ResourceSchedulingProperties resourceSchedulingProperties,
final ResourceSchedulingObserver resourceSchedulingObserver,
final Consumer<ResourceSchedulingDecisionInfo> schedulingDecisionInfoConsumer) {
final ResourceSchedulingDecisionInfo resourceSchedulingDecisionInfo = new ResourceSchedulingDecisionInfo();
final QueueType queueType = getQueueNameFromSchedulingProperties(queryContext, resourceSchedulingProperties);
resourceSchedulingDecisionInfo.setQueueName(queueType.name());
resourceSchedulingDecisionInfo.setQueueId(queueType.name());
resourceSchedulingDecisionInfo.setWorkloadClass(queryContext.getQueryContextInfo().getPriority().getWorkloadClass());
schedulingDecisionInfoConsumer.accept(resourceSchedulingDecisionInfo);
resourceSchedulingObserver.beginQueueWait();
final Pointer<DistributedSemaphore.DistributedLease> lease = new Pointer();
ListenableFuture<ResourceSet> futureAllocation = executorService.submit(() -> {
lease.value = acquireQuerySemaphoreIfNecessary(queryContext, queueType);
// update query limit based on the queueType
final OptionManager options = queryContext.getOptions();
// 此处基于了队列进行资源控制,但是没有利用上边的默认RuleBasedEngineSelector
final boolean memoryControlEnabled = options.getOption(BasicResourceConstants.ENABLE_QUEUE_MEMORY_LIMIT);
// TODO REFLECTION_SMALL, REFLECTION_LARGE was not there before - was it a bug???
final long memoryLimit = (queueType == QueueType.SMALL || queueType == QueueType.REFLECTION_SMALL) ?
options.getOption(BasicResourceConstants.SMALL_QUEUE_MEMORY_LIMIT):
options.getOption(BasicResourceConstants.LARGE_QUEUE_MEMORY_LIMIT);
long queryMaxAllocation = queryContext.getQueryContextInfo().getQueryMaxAllocation();
if (memoryControlEnabled && memoryLimit > 0) {
queryMaxAllocation = Math.min(memoryLimit, queryMaxAllocation);
}
final UserBitShared.QueryId queryId = queryContext.getQueryId();
final long queryMaxAllocationFinal = queryMaxAllocation;
final ResourceSet resourceSet = new BasicResourceSet(
queryId,
lease.value,
queryMaxAllocationFinal,
queueType.name());
return resourceSet;
});
Futures.addCallback(futureAllocation, new FutureCallback<ResourceSet>() {
@Override
public void onSuccess(@Nullable ResourceSet resourceSet) {
// don't need to do anything additional
}
@Override
public void onFailure(Throwable throwable) {
// need to close lease
releaseLease(lease.value);
}
}, executorService);
final ResourceSchedulingResult resourceSchedulingResult = new ResourceSchedulingResult(
resourceSchedulingDecisionInfo,
futureAllocation
);
return resourceSchedulingResult;
}
说明
RuleBasedEngineSelector 功能设计上主要是一个接口定义,对于资源分配需要依赖的可以直接使用,但是目前开源版本的比较弱
参考资料
https://docs.dremio.com/software/advanced-administration/jobs/
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
2020-03-11 postgresql_anonymizer 方便的数据脱敏扩展
2018-03-11 使用neon 开发nodejs addon
2017-03-11 Spring Cloud feign 服务超时处理