mirror of https://github.com/apache/lucene.git
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:
parent
a6cd8495bb
commit
3dead49181
|
@ -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)
|
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
|
Optimizations
|
||||||
----------------------
|
----------------------
|
||||||
1. SOLR-374: Use IndexReader.reopen to save resources by re-using parts of the
|
1. SOLR-374: Use IndexReader.reopen to save resources by re-using parts of the
|
||||||
|
|
|
@ -128,7 +128,7 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw
|
||||||
} else if (command.equals(CMD_GET_FILE_LIST)) {
|
} else if (command.equals(CMD_GET_FILE_LIST)) {
|
||||||
getFileList(solrParams, rsp);
|
getFileList(solrParams, rsp);
|
||||||
} else if (command.equals(CMD_SNAP_SHOOT)) {
|
} else if (command.equals(CMD_SNAP_SHOOT)) {
|
||||||
doSnapShoot(rsp);
|
doSnapShoot(solrParams, rsp);
|
||||||
} else if (command.equals(CMD_SNAP_PULL)) {
|
} else if (command.equals(CMD_SNAP_PULL)) {
|
||||||
new Thread() {
|
new Thread() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -244,11 +244,11 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw
|
||||||
return snapPullLock.isLocked();
|
return snapPullLock.isLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doSnapShoot(SolrQueryResponse rsp) {
|
private void doSnapShoot(SolrParams params, SolrQueryResponse rsp) {
|
||||||
try {
|
try {
|
||||||
IndexCommit indexCommit = core.getDeletionPolicy().getLatestCommit();
|
IndexCommit indexCommit = core.getDeletionPolicy().getLatestCommit();
|
||||||
if (indexCommit != null) {
|
if (indexCommit != null) {
|
||||||
new SnapShooter(core).createSnapAsync(indexCommit.getFileNames(), this);
|
new SnapShooter(core, params.get("location")).createSnapAsync(indexCommit.getFileNames(), this);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.warn("Exception during creating a snapshot", e);
|
LOG.warn("Exception during creating a snapshot", e);
|
||||||
|
@ -820,7 +820,7 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw
|
||||||
}
|
}
|
||||||
if (snapshoot) {
|
if (snapshoot) {
|
||||||
try {
|
try {
|
||||||
SnapShooter snapShooter = new SnapShooter(core);
|
SnapShooter snapShooter = new SnapShooter(core, null);
|
||||||
snapShooter.createSnapAsync(core.getDeletionPolicy().getLatestCommit().getFileNames(), ReplicationHandler.this);
|
snapShooter.createSnapAsync(core.getDeletionPolicy().getLatestCommit().getFileNames(), ReplicationHandler.this);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("Exception while snapshooting", e);
|
LOG.error("Exception while snapshooting", e);
|
||||||
|
|
|
@ -43,9 +43,15 @@ public class SnapShooter {
|
||||||
private SolrCore solrCore;
|
private SolrCore solrCore;
|
||||||
private SimpleFSLockFactory lockFactory;
|
private SimpleFSLockFactory lockFactory;
|
||||||
|
|
||||||
public SnapShooter(SolrCore core) throws IOException {
|
public SnapShooter(SolrCore core, String location) throws IOException {
|
||||||
solrCore = core;
|
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);
|
lockFactory = new SimpleFSLockFactory(snapDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue