|
54 | 54 | import org.apache.amoro.server.scheduler.inline.InlineTableExecutors; |
55 | 55 | import org.apache.amoro.server.table.DefaultTableManager; |
56 | 56 | import org.apache.amoro.server.table.DefaultTableService; |
57 | | -import org.apache.amoro.server.table.RuntimeHandlerChain; |
| 57 | +import org.apache.amoro.server.table.IcebergTablePlugin; |
58 | 58 | import org.apache.amoro.server.table.TableManager; |
59 | 59 | import org.apache.amoro.server.table.TableRuntimeFactoryManager; |
| 60 | +import org.apache.amoro.server.table.TableRuntimePlugin; |
60 | 61 | import org.apache.amoro.server.table.TableService; |
61 | 62 | import org.apache.amoro.server.terminal.TerminalManager; |
62 | 63 | import org.apache.amoro.server.utils.ThriftServiceProxy; |
@@ -198,12 +199,11 @@ public void waitFollowerShip() throws Exception { |
198 | 199 | haContainer.waitFollowerShip(); |
199 | 200 | } |
200 | 201 |
|
201 | | - public void startRestServices() throws Exception { |
| 202 | + public void startRestServices() { |
202 | 203 | EventsManager.getInstance(); |
203 | 204 | MetricManager.getInstance(); |
204 | 205 |
|
205 | 206 | catalogManager = new DefaultCatalogManager(serviceConfig); |
206 | | - tableManager = new DefaultTableManager(serviceConfig, catalogManager); |
207 | 207 | optimizerManager = new DefaultOptimizerManager(serviceConfig, catalogManager); |
208 | 208 | terminalManager = new TerminalManager(serviceConfig, catalogManager); |
209 | 209 |
|
@@ -234,38 +234,37 @@ public void startOptimizingService() throws Exception { |
234 | 234 |
|
235 | 235 | tableService = |
236 | 236 | new DefaultTableService(serviceConfig, catalogManager, tableRuntimeFactoryManager); |
237 | | - |
| 237 | + tableManager = new DefaultTableManager(serviceConfig, tableService); |
238 | 238 | optimizingService = |
239 | 239 | new DefaultOptimizingService(serviceConfig, catalogManager, optimizerManager, tableService); |
240 | 240 |
|
241 | 241 | processService = new ProcessService(serviceConfig, tableService); |
242 | | - |
243 | | - LOG.info("Setting up AMS table executors..."); |
244 | | - InlineTableExecutors.getInstance().setup(tableService, serviceConfig); |
245 | | - addHandlerChain(optimizingService.getTableRuntimeHandler()); |
246 | | - addHandlerChain(processService.getTableHandlerChain()); |
247 | | - addHandlerChain(InlineTableExecutors.getInstance().getDataExpiringExecutor()); |
248 | | - addHandlerChain(InlineTableExecutors.getInstance().getSnapshotsExpiringExecutor()); |
249 | | - addHandlerChain(InlineTableExecutors.getInstance().getOrphanFilesCleaningExecutor()); |
250 | | - addHandlerChain(InlineTableExecutors.getInstance().getDanglingDeleteFilesCleaningExecutor()); |
251 | | - addHandlerChain(InlineTableExecutors.getInstance().getOptimizingCommitExecutor()); |
252 | | - addHandlerChain(InlineTableExecutors.getInstance().getOptimizingExpiringExecutor()); |
253 | | - addHandlerChain(InlineTableExecutors.getInstance().getBlockerExpiringExecutor()); |
254 | | - addHandlerChain(InlineTableExecutors.getInstance().getHiveCommitSyncExecutor()); |
255 | | - addHandlerChain(InlineTableExecutors.getInstance().getTableRefreshingExecutor()); |
256 | | - addHandlerChain(InlineTableExecutors.getInstance().getTagsAutoCreatingExecutor()); |
257 | | - tableService.initialize(); |
| 242 | + tableService.initialize(initTablePlugins()); |
258 | 243 | LOG.info("AMS table service have been initialized"); |
259 | | - tableManager.setTableService(tableService); |
260 | 244 |
|
261 | 245 | initThriftService(); |
262 | 246 | startThriftService(); |
263 | 247 | } |
264 | 248 |
|
265 | | - private void addHandlerChain(RuntimeHandlerChain chain) { |
266 | | - if (chain != null) { |
267 | | - tableService.addHandlerChain(chain); |
268 | | - } |
| 249 | + private List<TableRuntimePlugin> initTablePlugins() { |
| 250 | + LOG.info("Setting up AMS table executors..."); |
| 251 | + InlineTableExecutors.getInstance().setup(tableService, serviceConfig); |
| 252 | + IcebergTablePlugin icebergTablePlugin = |
| 253 | + IcebergTablePlugin.builder() |
| 254 | + .addHandler(optimizingService.getTableRuntimeHandler()) |
| 255 | + .addHandler(processService.getTableHandlerChain()) |
| 256 | + .addHandler(InlineTableExecutors.getInstance().getDataExpiringExecutor()) |
| 257 | + .addHandler(InlineTableExecutors.getInstance().getSnapshotsExpiringExecutor()) |
| 258 | + .addHandler(InlineTableExecutors.getInstance().getOrphanFilesCleaningExecutor()) |
| 259 | + .addHandler(InlineTableExecutors.getInstance().getDanglingDeleteFilesCleaningExecutor()) |
| 260 | + .addHandler(InlineTableExecutors.getInstance().getOptimizingCommitExecutor()) |
| 261 | + .addHandler(InlineTableExecutors.getInstance().getOptimizingExpiringExecutor()) |
| 262 | + .addHandler(InlineTableExecutors.getInstance().getBlockerExpiringExecutor()) |
| 263 | + .addHandler(InlineTableExecutors.getInstance().getHiveCommitSyncExecutor()) |
| 264 | + .addHandler(InlineTableExecutors.getInstance().getTableRefreshingExecutor()) |
| 265 | + .addHandler(InlineTableExecutors.getInstance().getTagsAutoCreatingExecutor()) |
| 266 | + .build(); |
| 267 | + return List.of(icebergTablePlugin); |
269 | 268 | } |
270 | 269 |
|
271 | 270 | public void disposeOptimizingService() { |
|
0 commit comments