Github user hgadre commented on a diff in the pull request:
https://github.com/apache/lucene-solr/pull/52#discussion_r71748142
--- Diff:
solr/core/src/java/org/apache/solr/handler/admin/CoreAdminOperation.java ---
@@ -919,7 +928,93 @@ public void call(CallInfo callInfo) throws Exception {
}
}
}
+ },
+ CREATESNAPSHOT_OP(CREATESNAPSHOT) {
+ @Override
+ public void call(CallInfo callInfo) throws Exception {
+ CoreContainer cc = callInfo.handler.getCoreContainer();
+ final SolrParams params = callInfo.req.getParams();
+
+ String commitName =
params.required().get(CoreAdminParams.COMMIT_NAME);
+ String cname = params.required().get(CoreAdminParams.CORE);
+ try (SolrCore core = cc.getCore(cname)) {
+ if (core == null) {
+ throw new SolrException(ErrorCode.SERVER_ERROR, "Unable to
locate core " + cname);
+ }
+ if (core.getDeletionPolicy().getLatestCommit() == null) {
+ throw new SolrException(ErrorCode.SERVER_ERROR, "Could not find
latest commit. Please ensure to execute a hard commit");
+ }
+
+ String indexDirPath = core.getIndexDir();
+ IndexCommit ic = core.getDeletionPolicy().getLatestCommit();
+ SolrSnapshotMetaDataManager mgr =
core.getSnapshotMetaDataManager();
+ mgr.snapshot(commitName, indexDirPath, ic.getGeneration());
+ }
+ }
+ },
+ DELETESNAPSHOT_OP(DELETESNAPSHOT) {
+ @Override
+ public void call(CallInfo callInfo) throws Exception {
+ CoreContainer cc = callInfo.handler.getCoreContainer();
+ final SolrParams params = callInfo.req.getParams();
+
+ String commitName =
params.required().get(CoreAdminParams.COMMIT_NAME);
+ String cname = params.required().get(CoreAdminParams.CORE);
+ try (SolrCore core = cc.getCore(cname)) {
+ if (core == null) {
+ throw new SolrException(ErrorCode.SERVER_ERROR, "Unable to
locate core " + cname);
+ }
+
+ SolrSnapshotMetaDataManager mgr =
core.getSnapshotMetaDataManager();
+ Optional<SnapshotMetaData> metadata = mgr.release(commitName);
+ if (metadata.isPresent()) {
--- End diff --
OK I am using BAD_REQUEST for parameter related errors. I don't think we
should throw error if the commit is not found since this is in-line with the
user expectation (which is Solr should not have a snapshot with the specified
name).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]