diff --git a/CHANGES.txt b/CHANGES.txt index f57e6550e10..106fafdfec3 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -228,6 +228,8 @@ New Features 56. SOLR-1051: Support the merge of multiple indexes as a CoreAdmin and an update command (Ning Li via shalin) +57. SOLR-1152: Snapshoot on ReplicationHandler should acccept location as a request parameter (shalin) + Optimizations ---------------------- 1. SOLR-374: Use IndexReader.reopen to save resources by re-using parts of the diff --git a/src/java/org/apache/solr/handler/ReplicationHandler.java b/src/java/org/apache/solr/handler/ReplicationHandler.java index 578ab6e64fa..72678caee56 100644 --- a/src/java/org/apache/solr/handler/ReplicationHandler.java +++ b/src/java/org/apache/solr/handler/ReplicationHandler.java @@ -128,7 +128,7 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw } else if (command.equals(CMD_GET_FILE_LIST)) { getFileList(solrParams, rsp); } else if (command.equals(CMD_SNAP_SHOOT)) { - doSnapShoot(rsp); + doSnapShoot(solrParams, rsp); } else if (command.equals(CMD_SNAP_PULL)) { new Thread() { public void run() { @@ -244,11 +244,11 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw return snapPullLock.isLocked(); } - private void doSnapShoot(SolrQueryResponse rsp) { + private void doSnapShoot(SolrParams params, SolrQueryResponse rsp) { try { IndexCommit indexCommit = core.getDeletionPolicy().getLatestCommit(); if (indexCommit != null) { - new SnapShooter(core).createSnapAsync(indexCommit.getFileNames(), this); + new SnapShooter(core, params.get("location")).createSnapAsync(indexCommit.getFileNames(), this); } } catch (Exception e) { LOG.warn("Exception during creating a snapshot", e); @@ -820,7 +820,7 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw } if (snapshoot) { try { - SnapShooter snapShooter = new SnapShooter(core); + SnapShooter snapShooter = new SnapShooter(core, null); snapShooter.createSnapAsync(core.getDeletionPolicy().getLatestCommit().getFileNames(), ReplicationHandler.this); } catch (Exception e) { LOG.error("Exception while snapshooting", e); diff --git a/src/java/org/apache/solr/handler/SnapShooter.java b/src/java/org/apache/solr/handler/SnapShooter.java index 37f7e731ec2..d16804a07de 100644 --- a/src/java/org/apache/solr/handler/SnapShooter.java +++ b/src/java/org/apache/solr/handler/SnapShooter.java @@ -43,9 +43,15 @@ public class SnapShooter { private SolrCore solrCore; private SimpleFSLockFactory lockFactory; - public SnapShooter(SolrCore core) throws IOException { + public SnapShooter(SolrCore core, String location) throws IOException { solrCore = core; - snapDir = core.getDataDir(); + if (location == null) snapDir = core.getDataDir(); + else { + File base = new File(core.getCoreDescriptor().getInstanceDir()); + snapDir = org.apache.solr.common.util.FileUtils.resolvePath(base, location).getAbsolutePath(); + File dir = new File(snapDir); + if (!dir.exists()) dir.mkdirs(); + } lockFactory = new SimpleFSLockFactory(snapDir); }