Github user dsmiley commented on a diff in the pull request:

    https://github.com/apache/lucene-solr/pull/52#discussion_r71725843
  
    --- 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 --
    
    Perhaps add an error if we can't find the commit name?  REQUEST_ERROR.  And 
FYI some other exceptions we throw should also be REQUEST_ERROR if it's based 
on a param.


---
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]

Reply via email to