Skip to content

Commit

Permalink
Initialize planner beans lazily
Browse files Browse the repository at this point in the history
  • Loading branch information
sopel39 committed Apr 26, 2021
1 parent 93bc1e1 commit f3dda9c
Showing 1 changed file with 14 additions and 8 deletions.
Expand Up @@ -228,7 +228,6 @@
import io.trino.sql.planner.optimizations.WindowFilterPushDown;
import org.weakref.jmx.MBeanExporter;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;

Expand All @@ -245,6 +244,8 @@ public class PlanOptimizers
private final OptimizerStatsRecorder optimizerStats = new OptimizerStatsRecorder();
private final MBeanExporter exporter;

private boolean initialized;

@Inject
public PlanOptimizers(
Metadata metadata,
Expand Down Expand Up @@ -279,13 +280,6 @@ public PlanOptimizers(
nodePartitioningManager);
}

@PostConstruct
public void initialize()
{
ruleStats.export(exporter);
optimizerStats.export(exporter);
}

@PreDestroy
public void destroy()
{
Expand Down Expand Up @@ -896,6 +890,18 @@ public PlanOptimizers(
@Override
public List<PlanOptimizer> get()
{
initialize();
return optimizers;
}

private synchronized void initialize()
{
if (initialized) {
return;
}

ruleStats.export(exporter);
optimizerStats.export(exporter);
initialized = true;
}
}

0 comments on commit f3dda9c

Please sign in to comment.