0
点赞
收藏
分享

微信扫一扫

dremio DACModule 模块简单说明

他说Python 2023-02-28 阅读 89

DACModule 核心是进行dac 一个帮助类,进行一些依赖的处理,方便在DACDaemon 中使用,同时官方为了支持自定义
基于动态类创建进行了扩展(DremioDaemon 处理的)

接口定义

参考类图

dremio DACModule  模块简单说明_bootstrap

 

 

备注: 会发现包含两个SingletonRegistry (bootstrap的以及一个普通的,主要是不同优先级的服务处理),会将不同的服务模块注册到ioc 容器中,方便共享
使用

参考实现

包含了一个默认实现DACDaemonModule,以及几个方便测试的,如下

dremio DACModule  模块简单说明_ide_02

 

 

bootstrapRegistry 注册的服务

包含了bootstap context ,内存分配,集群协调器,master 选举服务,请求上下文等,会对于不同的节点角色提供不能的服务注册
参加如下

public void bootstrap(final Runnable shutdownHook, final SingletonRegistry bootstrapRegistry, ScanResult scanResult, DACConfig dacConfig, boolean isMaster) {
final DremioConfig config = dacConfig.getConfig();
final boolean embeddedZookeeper = config.getBoolean(DremioConfig.EMBEDDED_MASTER_ZK_ENABLED_BOOL);
final BootStrapContext bootStrapContext = new BootStrapContext(config, scanResult, bootstrapRegistry);
boolean isMasterless = config.isMasterlessEnabled();

bootstrapRegistry.bindSelf(bootStrapContext);

bootstrapRegistry.bind(BufferAllocator.class, bootStrapContext.getAllocator());

// Start cluster coordinator before all other services so that non master nodes can poll for master status
if (dacConfig.getClusterMode() == ClusterMode.LOCAL) {
bootstrapRegistry.bind(ClusterCoordinator.class, new LocalClusterCoordinator());
} else if (config.getBoolean(DremioConfig.NO_OP_CLUSTER_COORDINATOR_ENABLED)) {
isMasterless = true;
Preconditions.checkState(!isMaster);
bootstrapRegistry.bind(ClusterCoordinator.class, new NoOpClusterCoordinator());
} else {
// ClusterCoordinator has a runtime dependency on ZooKeeper. If no ZooKeeper server
// is present, ClusterCoordinator won't start, so this service should be initialized first.
final Provider<Integer> portProvider;
if (isMaster && embeddedZookeeper) {
ZkServer zkServer = new ZkServer(
config.getString(DremioConfig.EMBEDDED_MASTER_ZK_ENABLED_PATH_STRING),
config.getInt(DremioConfig.EMBEDDED_MASTER_ZK_ENABLED_PORT_INT),
dacConfig.autoPort);
bootstrapRegistry.bindSelf(zkServer);

portProvider = dacConfig.autoPort ? new Provider<Integer>(){
@Override
public Integer get() {
return bootstrapRegistry.lookup(ZkServer.class).getPort();
}} : null;
} else {
portProvider = null;
}

final ZKClusterCoordinator coord;
try {
coord = new ZKClusterCoordinator(config.getSabotConfig(), portProvider);
} catch (IOException e) {
throw new RuntimeException("Cannot instantiate the ZooKeeper cluster coordinator", e);
}
bootstrapRegistry.bind(ClusterCoordinator.class, coord);
}

// Start master election
if (isMaster && !config.getBoolean(DremioConfig.DEBUG_DISABLE_MASTER_ELECTION_SERVICE_BOOL)) {
bootstrapRegistry.bindSelf(new MasterElectionService(bootstrapRegistry.provider(ClusterCoordinator.class)));
}

final MasterStatusListener masterStatusListener;
final Provider<ClusterServiceSetManager> clusterServiceSetManagerProvider =
() -> bootstrapRegistry.provider(ClusterCoordinator.class).get();

if (!isMasterless) {
masterStatusListener = new MasterStatusListener(clusterServiceSetManagerProvider, config.getSabotConfig(), isMaster);
} else {
masterStatusListener =
new MasterlessStatusListener(clusterServiceSetManagerProvider, isMaster);
}
// start master status listener
bootstrapRegistry.bind(MasterStatusListener.class, masterStatusListener);
bootstrapRegistry.bindProvider(EngineId.class, Providers.of(null));
bootstrapRegistry.bindProvider(SubEngineId.class, Providers.of(null));

// Default request Context
bootstrapRegistry.bind(RequestContext.class,
RequestContext.empty()
.with(TenantContext.CTX_KEY, TenantContext.DEFAULT_SERVICE_CONTEXT)
.with(UserContext.CTX_KEY, UserContext.SYSTEM_USER_CONTEXT)
);

}

普通registry注册的服务

普通registry注册的服务就比较多了,包含了不少能力,也是dremio 节点的一些核心能力模块
具体参考build 方法,注意此处也依赖了bootstrapRegistry,会将一些注册的binding 复制到普通registry 中
具体的代码比较多,核心是对于dremio的服务进行注册到ioc 容器中,包含了:执行服务(ExecutorService)
内存分配器工厂(集成了bootstrapRegistry的),ConnectionReader(数据连接读取的)rpc 处理,fabric 服务
身份服务,ConduitServiceRegistry,ConduitServer,ConduitInProcessChannelProvider,kv 存储,整理的一些参考注册服务(很多,将dremio
的核心服务都关联起来了,比如认证,反射加速,数据源数据,catalog服务,namespace 服务,taskpool 任务执行服务。。。。),参考如下
InformationSchemaServiceBlockingStub,DatasetCatalogServiceBlockingStub,ProjectRoleInitializer,ViewCreatorFactory,UserServer,ContextService,SabotContext, NodeEndpoint,NamespaceService,DatasetListingService,CoordExecService,HomeFileTool,SchedulerService,SystemOptionManager,OptionManager,SplitOrphansCleanerService,SpillService,CatalogService,CommandPool,LocalJobsService,SimpleJobRunner,ProvisioningService,ResourceAllocator,ExecutorSelectionService,MaestroForwarder,MaestroServicem,RuleBasedEngineSelector,foremenWorkManager,UserWorker,ContextInformationFactory,TaskPool,workloadTicketDepotService,JobResultsClientFactory,fragmentWorkManager,AccelerationManager,StatisticsService,JobsService,ReflectionService,ReflectionStatusService,ServerHealthMonitor,SupportService,NodeRegistration,SearchService,RestServerV2,APIServer,DremioServlet,SourceService,DremioFlightService,NessieService,UserPreferenceService,WebServer,TokenManager

说明

以上是一个简单的说明,如果希望完整的了解组件的关联关系,可以详细阅读的源码,部分组件我以前也简单的介绍过,可以参考,后边我也会详细介绍下

参考资料

dac/backend/src/main/java/com/dremio/dac/daemon/DACModule.java
dac/backend/src/main/java/com/dremio/dac/daemon/DACDaemonModule.java
dac/backend/src/test/java/com/dremio/dac/server/TestMultiMaster.java
dac/backend/src/test/java/com/dremio/dac/server/TestServerTracing.java
dac/backend/src/main/java/com/dremio/dac/daemon/DACDaemon.java

举报

相关推荐

0 条评论