kfaraz commented on code in PR #16127:
URL: https://github.com/apache/druid/pull/16127#discussion_r1525728167
##########
server/src/main/java/org/apache/druid/server/http/DataSourcesResource.java:
##########
@@ -278,13 +284,14 @@ public Response markSegmentsAsUnused(
);
return numUpdatedSegments;
};
- return performSegmentUpdate(dataSourceName, payload, operation);
+ return performSegmentUpdate(dataSourceName, payload, operation, true);
}
private Response performSegmentUpdate(
String dataSourceName,
MarkDataSourceSegmentsPayload payload,
- SegmentUpdateOperation operation
+ SegmentUpdateOperation operation,
+ boolean validateDatasourceIsQueryable
Review Comment:
Yeah, boolean args are always weird. How about we do this instead.
- Get rid of the `performSegmentUpdate` method, the one which accepts a
`MarkDataSourceSegmentsPayload`.
- Create method `buildInvalidMarkSegmentsPayloadResponse`
Then, our methods would look like this, and it would be readily evident
where we want to perform which validations:
```java
public Response markAsUsedNonOvershadowedSegments()
{
final SegmentUpdateOperation operation = ...
if (payload == null || !payload.isValid()) {
return buildInvalidMarkSegmentsPayloadResponse(payload);
} else {
return performSegmentUpdate(dataSourceName, operation);
}
}
```
```java
public Response markSegmentsAsUnused()
{
final SegmentUpdateOperation operation = ...
if (payload == null || !payload.isValid()) {
return buildInvalidMarkSegmentsPayloadResponse(payload);
} else if (getQueryableDatasource(dataSourceName) == null) {
return logAndCreateDataSourceNotFoundResponse(dataSourceName);
} else {
return performSegmentUpdate(dataSourceName, operation);
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]