Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOLR-16699: Expose creationTimeMillis in COLSTATUS API #2226

Merged
merged 5 commits into from
Feb 1, 2024

Conversation

pjmcarthur
Copy link
Contributor

https://issues.apache.org/jira/browse/SOLR-16699

Description

The collection creation time is now exposed in the solrj DocCollection and the COLSTATUS API.

Solution

The creation time comes from the ctime value of the ZooKeeper node for the collection.

Tests

Added a test to verify the presence and value of the creationTimeMillis attribute in the DocCollection and COLSTATUS API response.

Checklist

Please review the following and check all that apply:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.
  • I have added documentation for the Reference Guide

@github-actions github-actions bot added documentation Improvements or additions to documentation client:solrj labels Jan 26, 2024
Comment on lines 225 to 227
// set a default created date, we don't aim at reading actual zookeeper state. The restored
// collection
// will have a new creation date when persisted in zookeeper.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reflow

@@ -345,6 +346,16 @@ private void clusterStatusWithCollectionAndMultipleShards()
}
}

private Instant getCreationTimeFromClusterStateOrFail(
CloudSolrClient client, String collectionName) throws IOException {
DocCollection docCollection = client.getClusterState().getCollectionOrNull(collectionName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why call the OrNull version; why not let the default impl throw its own exception? That's what its for.

@@ -549,4 +523,9 @@ public void testSingleExternalCollectionCompressedState() throws Exception {
server.shutdown();
}
}

private DocCollection createDocCollection(String name, Map<String, Object> props) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

glad to see this; simplified the test

Comment on lines 398 to 400
* When this DocCollection is read from Zookeeper, it captures a collection persisted in
* Zookeeper. The date thus captures the date when the collection node was created, and thus the
* collection made usable by APIs as specified by {@code ZkStateReader#getCollectionPath(String)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should start with a simple sentence like "The creation time of this collection." Perhaps say it's never null. Then the proposed text.

import org.junit.Before;
import org.junit.Test;

public class BaseHttpClusterStateProviderTest extends SolrCloudTestCase {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test does not need to exist or could be converted to something generic. A ClusterStateProvider is an abstraction with equivalent implementations -- and thus could be chosen arbitrarily in some other test that checks the time that otherwise doesn't really care about ZK or Http for that matter. Many things in Lucene and Solr are tested embracing this philosophy and I count myself a convert. "randomized testing". Maybe an existing test that checks creation time could be retrofitted to use the cluster state provider impl randomly? Or alternatively since there are 2, make a generic test that is parameterized for the two (example of the approach -- TestConfigSetService)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this comment, it was useful. I have recreated this test in ClusterStateProviderTest to implement the suggestion.

Copy link
Contributor

@dsmiley dsmiley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 Awesome; this is ready to ship! I'll wait till tomorrow to merge in case there is any other feedback.

@dsmiley
Copy link
Contributor

dsmiley commented Jan 31, 2024

ReindexCollection.testAbort fails sometimes; isn't caused by this change. -- http://fucit.org/solr-jenkins-reports/failure-report.html

@dsmiley dsmiley merged commit 61cf8f8 into apache:main Feb 1, 2024
3 of 4 checks passed
dsmiley added a commit that referenced this pull request Feb 1, 2024
…US API responses (#2226)

Using ZooKeeper "ctime" of the node.

Co-authored-by: Julien Pilourdault
Co-authored-by: Paul McArthur <pmcarthur-apache@proton.me>
Co-authored-by: David Smiley <dsmiley@salesforce.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client:solrj documentation Improvements or additions to documentation
Projects
None yet
3 participants