mirror of
https://github.com/apache/lucene.git
synced 2025-02-12 13:05:29 +00:00
SOLR-4203: empty the tlog dir without instantiating an updatelog
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1422746 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
099a5dcb78
commit
0a73b63883
@ -18,10 +18,10 @@
|
|||||||
package org.apache.solr.update;
|
package org.apache.solr.update;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
import org.apache.solr.core.PluginInfo;
|
import org.apache.solr.core.PluginInfo;
|
||||||
import org.apache.solr.core.SolrCore;
|
import org.apache.solr.core.SolrCore;
|
||||||
import org.apache.solr.core.SolrEventListener;
|
import org.apache.solr.core.SolrEventListener;
|
||||||
@ -74,8 +74,7 @@ public abstract class UpdateHandler implements SolrInfoMBean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void initLog() {
|
private void initLog(PluginInfo ulogPluginInfo) {
|
||||||
PluginInfo ulogPluginInfo = core.getSolrConfig().getPluginInfo(UpdateLog.class.getName());
|
|
||||||
if (ulogPluginInfo != null && ulogPluginInfo.isEnabled()) {
|
if (ulogPluginInfo != null && ulogPluginInfo.isEnabled()) {
|
||||||
ulog = new UpdateLog();
|
ulog = new UpdateLog();
|
||||||
ulog.init(ulogPluginInfo);
|
ulog.init(ulogPluginInfo);
|
||||||
@ -85,11 +84,16 @@ public abstract class UpdateHandler implements SolrInfoMBean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// not thread safe - for startup
|
// not thread safe - for startup
|
||||||
protected void clearLog() throws IOException {
|
private void clearLog(PluginInfo ulogPluginInfo) {
|
||||||
if (ulog != null) {
|
if (ulog != null) {
|
||||||
ulog.close(false, true);
|
String[] files = UpdateLog.getLogList(UpdateLog.getTlogDir(ulogPluginInfo));
|
||||||
//FileUtils.deleteDirectory(ulog.getLogDir());
|
for (String file : files) {
|
||||||
initLog();
|
File f = new File(file);
|
||||||
|
boolean s = f.delete();
|
||||||
|
if (!s) {
|
||||||
|
log.error("Could not remove tlog file:" + f);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,14 +121,11 @@ public abstract class UpdateHandler implements SolrInfoMBean {
|
|||||||
idField = schema.getUniqueKeyField();
|
idField = schema.getUniqueKeyField();
|
||||||
idFieldType = idField!=null ? idField.getType() : null;
|
idFieldType = idField!=null ? idField.getType() : null;
|
||||||
parseEventListeners();
|
parseEventListeners();
|
||||||
initLog();
|
PluginInfo ulogPluginInfo = core.getSolrConfig().getPluginInfo(UpdateLog.class.getName());
|
||||||
if (!core.isReloaded() && !core.getDirectoryFactory().isPersistent()) {
|
if (!core.isReloaded() && !core.getDirectoryFactory().isPersistent()) {
|
||||||
try {
|
clearLog(ulogPluginInfo);
|
||||||
clearLog();
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
initLog(ulogPluginInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1394,6 +1394,12 @@ public class UpdateLog implements PluginInfoInitialized {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static File getTlogDir(PluginInfo info) {
|
||||||
|
String dataDir = (String)info.initArgs.get("dir");
|
||||||
|
return new File(dataDir, TLOG_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user