Re-enable centalized schema with no query embedded tests#18561
Re-enable centalized schema with no query embedded tests#18561kfaraz merged 3 commits intoapache:masterfrom
Conversation
| * to be queryable by Brokers. | ||
| */ | ||
| public void waitForAllSegmentsToBeAvailable(String dataSource, EmbeddedCoordinator coordinator, EmbeddedBroker broker) | ||
| public void waitForAllSegmentsToBeAvailable( |
There was a problem hiding this comment.
We shouldn't change this method. Please add a new method which waits on the new metric.
| final String taskId = IdUtils.getRandomId(); | ||
| cluster.callApi().runTask(taskBuilder.dataSource(dataSource).withId(taskId), overlord); | ||
| cluster.callApi().waitForAllSegmentsToBeAvailable(dataSource, coordinator, broker); | ||
| boolean useCentralizedSchema = Boolean.parseBoolean((String) cluster.getCommonProperties().getOrDefault("druid.centralizedDatasourceSchema.enabled", "false")); |
There was a problem hiding this comment.
| boolean useCentralizedSchema = Boolean.parseBoolean((String) cluster.getCommonProperties().getOrDefault("druid.centralizedDatasourceSchema.enabled", "false")); | |
| boolean useCentralizedSchema = Boolean.parseBoolean(cluster.getCommonProperties().getProperty("druid.centralizedDatasourceSchema.enabled", "false")); |
| .addCommonProperty("druid.centralizedDatasourceSchema.backFillEnabled", "true") | ||
| .addCommonProperty("druid.centralizedDatasourceSchema.backFillPeriod", "500") | ||
| .addCommonProperty("druid.coordinator.segmentMetadata.disableSegmentMetadataQueries", "true") | ||
| .addCommonProperty("druid.sql.planner.metadataRefreshPeriod", "PT0.1s") |
There was a problem hiding this comment.
This property is already added to EmbeddedBroker. Do we need to add it here too?
| polledDataSourceMetadata.forEach(this::updateDSMetadata); | ||
|
|
||
| // Remove segments of the datasource from refresh list for which we received schema from the Coordinator. | ||
| final Map<String, Integer> segmentsSkippedPerDatasource = new HashMap<>(); |
There was a problem hiding this comment.
| final Map<String, Integer> segmentsSkippedPerDatasource = new HashMap<>(); | |
| final Map<String, Integer> datasourceToNumSegmentsSkipped = new HashMap<>(); |
| emitMetric(Metric.BROKER_SEGMENTS_SKIPPED_REFRESH, count, | ||
| new ServiceMetricEvent.Builder().setDimension(DruidMetrics.DATASOURCE, dataSource)); |
There was a problem hiding this comment.
Please put each arg in a separate line.
| segmentsToRefresh.removeIf(segmentId -> polledDataSourceMetadata.containsKey(segmentId.getDataSource())); | ||
|
|
||
| // Emit metrics per datasource | ||
| segmentsSkippedPerDatasource.forEach((dataSource, count) -> { |
There was a problem hiding this comment.
Nit: Lambda can be simplified
| polledDataSourceMetadata.forEach(this::updateDSMetadata); | ||
|
|
||
| // Remove segments of the datasource from refresh list for which we received schema from the Coordinator. | ||
| final Map<String, Integer> segmentsSkippedPerDatasource = new HashMap<>(); |
There was a problem hiding this comment.
Please put the entire new logic in a separate method.
| // Emit metrics per datasource | ||
| datasourceToNumSegmentsSkipped.forEach( | ||
| (dataSource, count) -> | ||
| emitMetric( | ||
| Metric.BROKER_SEGMENTS_SKIPPED_REFRESH, | ||
| count, | ||
| new ServiceMetricEvent.Builder().setDimension( | ||
| DruidMetrics.DATASOURCE, | ||
| dataSource)) | ||
| ); |
There was a problem hiding this comment.
This should be put in the new method as well.
| } | ||
| } | ||
|
|
||
| private Map<String, Integer> getDatasourceToSegmentsSkipped( |
There was a problem hiding this comment.
| private Map<String, Integer> getDatasourceToSegmentsSkipped( | |
| private void emitMetricForSkippedSegments( |
| datasourceToNumSegmentsSkipped.merge(segmentId.getDataSource(), 1, Integer::sum); | ||
| } | ||
| } | ||
| return datasourceToNumSegmentsSkipped; |
There was a problem hiding this comment.
Don't return anything. Perform the metric emission here itself.
| new ServiceMetricEvent.Builder().setDimension( | ||
| DruidMetrics.DATASOURCE, | ||
| dataSource)) |
There was a problem hiding this comment.
| new ServiceMetricEvent.Builder().setDimension( | |
| DruidMetrics.DATASOURCE, | |
| dataSource)) | |
| new ServiceMetricEvent.Builder().setDimension(DruidMetrics.DATASOURCE, dataSource) | |
| ) |
|
Thanks for your review @kfaraz , I've accommodated the review comments, PTAL |
As follow-up of #18497 , this PR re-enables the embedded tests in
CentralizedSchemaMetadataQueryDisabledTestWeirdly, this is not unblocking
CentralizedSchemaPublishFailureTest(the no. of segments skipped and the no. of segments refreshed seems to be changing erratically in tests and is never what we want, will take a look at those tests in separate PR.)