druid icon indicating copy to clipboard operation
druid copied to clipboard

Add versions to `markUsed` and `markUnused` APIs

Open abhishekrb19 opened this issue 1 year ago • 0 comments

Follow up to https://github.com/apache/druid/pull/15994, this patch adds support for versions to the markUsed and markUnused APIs.

Segments can now be marked as used or unused within the specified interval using an optional list of versions, i.e., (interval, [versions]). When versions is unspecified, all versions of segments in the interval are marked as used or unused, preserving the old behavior before this patch.

Release note

Segments can now be marked as used or unused within the specified interval using an optional list of versions, i.e., (interval, [versions]). When versions is unspecified, all versions of segments in the interval are marked as used or unused, preserving the old behavior.

Sample markUsed API with versions:

curl 'http://localhost:8888/druid/coordinator/v1/datasources/foo/markUsed' \
  -H 'Accept: application/json, text/plain, */*' \
  -H 'Content-Type: application/json' \
  -H 'Origin: http://localhost:8888' \
  --data-raw '{"interval":"2020/2030", "versions": ["2024-03-14T13:30:54.460Z"]}' 

{"numChangedSegments":15}

Sample markUnused API with versions:

curl 'http://localhost:8888/druid/coordinator/v1/datasources/foo/markUnused' \
  -H 'Accept: application/json, text/plain, */*' \
  -H 'Content-Type: application/json' \
  -H 'Origin: http://localhost:8888' \
  --data-raw '{"interval":"2020/2030", "versions": ["2024-03-14T16:00:04.086Z"]}' 

{"numChangedSegments":15}

Key changed/added classes in this PR
  • SegmentsMetadataManager.java
  • SqlSegmentsMetadataManager.java
  • SqlSegmentsMetadataQuery.java
  • DatasourcesResource.java

This PR has:

  • [x] been self-reviewed.
  • [x] added documentation for new or modified features or behaviors.
  • [x] a release note entry in the PR description.
  • [x] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • [x] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • [x] been tested in a test Druid cluster.

abhishekrb19 avatar Mar 15 '24 22:03 abhishekrb19