SOLR-1152 -- Snapshoot on ReplicationHandler should acccept location as a request parameter

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@779497 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2009-05-28 09:11:12 +00:00
parent a6cd8495bb
commit 3dead49181
3 changed files with 14 additions and 6 deletions

View File

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

View File

@ -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);

View File

@ -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);
}