Skip to content

Commit

Permalink
Add stats to track the number of replaced non-alive nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
NikhilCollooru authored and shixuan-fan committed Jul 30, 2021
1 parent 587cf72 commit 254a02e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class NodeSelectionStats

private final CounterStat bucketedPreferredNodeSelectedCount = new CounterStat();
private final CounterStat bucketedNonPreferredNodeSelectedCount = new CounterStat();
private final CounterStat bucketedNonAliveNodeReplacedCount = new CounterStat();

private final CounterStat preferredNonAliveNodeSkippedCount = new CounterStat();

Expand Down Expand Up @@ -56,6 +57,11 @@ public void incrementBucketedNonPreferredNodeSelectedCount()
bucketedNonPreferredNodeSelectedCount.update(1);
}

public void incrementBucketedNonAliveNodeReplacedCount()
{
bucketedNonAliveNodeReplacedCount.update(1);
}

public void incrementPreferredNonAliveNodeSkippedCount()
{
preferredNonAliveNodeSkippedCount.update(1);
Expand Down Expand Up @@ -102,4 +108,11 @@ public CounterStat getPreferredNonAliveNodeSkippedCount()
{
return preferredNonAliveNodeSkippedCount;
}

@Managed
@Nested
public CounterStat getBucketedNonAliveNodeReplacedCount()
{
return bucketedNonAliveNodeReplacedCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.facebook.presto.execution.scheduler.FixedBucketNodeMap;
import com.facebook.presto.execution.scheduler.NodeScheduler;
import com.facebook.presto.execution.scheduler.group.DynamicBucketNodeMap;
import com.facebook.presto.execution.scheduler.nodeSelection.NodeSelectionStats;
import com.facebook.presto.metadata.InternalNode;
import com.facebook.presto.metadata.Split;
import com.facebook.presto.operator.BucketPartitionFunction;
Expand Down Expand Up @@ -58,12 +59,14 @@ public class NodePartitioningManager
{
private final NodeScheduler nodeScheduler;
private final PartitioningProviderManager partitioningProviderManager;
private final NodeSelectionStats nodeSelectionStats;

@Inject
public NodePartitioningManager(NodeScheduler nodeScheduler, PartitioningProviderManager partitioningProviderManager)
public NodePartitioningManager(NodeScheduler nodeScheduler, PartitioningProviderManager partitioningProviderManager, NodeSelectionStats nodeSelectionStats)
{
this.nodeScheduler = requireNonNull(nodeScheduler, "nodeScheduler is null");
this.partitioningProviderManager = requireNonNull(partitioningProviderManager, "partitioningProviderManager is null");
this.nodeSelectionStats = requireNonNull(nodeSelectionStats, "nodeSelectionStats is null");
}

public PartitionFunction getPartitionFunction(
Expand Down Expand Up @@ -274,6 +277,7 @@ public List<Node> getNodes(Session session, ConnectorId connectorId)
node = allNodes.get(index);
index = (index + 1) % nodeCount;
}
nodeSelectionStats.incrementBucketedNonAliveNodeReplacedCount();
}
nodeBuilder.add(node);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ private LocalQueryRunner(Session defaultSession, FeaturesConfig featuresConfig,
catalogManager,
notificationExecutor);
this.partitioningProviderManager = new PartitioningProviderManager();
this.nodePartitioningManager = new NodePartitioningManager(nodeScheduler, partitioningProviderManager);
this.nodePartitioningManager = new NodePartitioningManager(nodeScheduler, partitioningProviderManager, new NodeSelectionStats());
this.planOptimizerManager = new ConnectorPlanOptimizerManager();
this.distributedMetadataManager = new ConnectorMetadataUpdaterManager();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void setUp()
new NodeSchedulerConfig().setIncludeCoordinator(true),
new NodeTaskMap(finalizerService));
PartitioningProviderManager partitioningProviderManager = new PartitioningProviderManager();
nodePartitioningManager = new NodePartitioningManager(nodeScheduler, partitioningProviderManager);
nodePartitioningManager = new NodePartitioningManager(nodeScheduler, partitioningProviderManager, new NodeSelectionStats());
planFragmenter = new PlanFragmenter(metadata, nodePartitioningManager, new QueryManagerConfig(), new SqlParser(), new FeaturesConfig());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public static LocalExecutionPlanner createTestingPlanner()
new NodeSchedulerConfig().setIncludeCoordinator(true),
new NodeTaskMap(finalizerService));
PartitioningProviderManager partitioningProviderManager = new PartitioningProviderManager();
NodePartitioningManager nodePartitioningManager = new NodePartitioningManager(nodeScheduler, partitioningProviderManager);
NodePartitioningManager nodePartitioningManager = new NodePartitioningManager(nodeScheduler, partitioningProviderManager, new NodeSelectionStats());

PageFunctionCompiler pageFunctionCompiler = new PageFunctionCompiler(metadata, 0);
return new LocalExecutionPlanner(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.facebook.presto.Session;
import com.facebook.presto.common.type.Type;
import com.facebook.presto.execution.scheduler.BucketNodeMap;
import com.facebook.presto.execution.scheduler.nodeSelection.NodeSelectionStats;
import com.facebook.presto.operator.PartitionFunction;
import com.facebook.presto.spi.connector.ConnectorPartitionHandle;
import com.facebook.presto.sql.planner.NodePartitionMap;
Expand All @@ -37,7 +38,7 @@ public class PrestoSparkNodePartitioningManager
@Inject
public PrestoSparkNodePartitioningManager(PartitioningProviderManager partitioningProviderManager)
{
super(new PrestoSparkNodeScheduler(), partitioningProviderManager);
super(new PrestoSparkNodeScheduler(), partitioningProviderManager, new NodeSelectionStats());
}

@Override
Expand Down

0 comments on commit 254a02e

Please sign in to comment.