refactoring of reindexSolr (just replaced constant string)

pull/1/head
Michael Peter Christen 10 years ago
parent b5a55c8b3d
commit 5a060c9f26

@ -36,14 +36,14 @@ public class IndexReIndexMonitor_p {
prop.put("docsprocessed", "0");
prop.put("currentselectquery","");
BusyThread bt = sb.getThread("reindexSolr");
BusyThread bt = sb.getThread(ReindexSolrBusyThread.THREAD_NAME);
if (bt == null) {
if (post != null && post.containsKey("reindexnow") && sb.index.fulltext().connectedLocalSolr()) {
migration.reindexToschema(sb);
prop.put("querysize", "0");
prop.put("infomessage","reindex job started");
bt = sb.getThread("reindexSolr"); //get new created job for following posts
bt = sb.getThread(ReindexSolrBusyThread.THREAD_NAME); //get new created job for following posts
}
}
@ -70,7 +70,7 @@ public class IndexReIndexMonitor_p {
}
if (post != null && post.containsKey("stopreindex")) {
sb.terminateThread("reindexSolr", false);
sb.terminateThread(ReindexSolrBusyThread.THREAD_NAME, false);
prop.put("infomessage", "reindex job stopped");
prop.put("reindexjobrunning",0);
} else {

@ -293,7 +293,7 @@ public class migration {
*/
public static int reindexToschema (final Switchboard sb) {
BusyThread bt = sb.getThread("reindexSolr");
BusyThread bt = sb.getThread(ReindexSolrBusyThread.THREAD_NAME);
// a reindex job is already running
if (bt != null) {
return bt.getJobCount();
@ -363,7 +363,7 @@ public class migration {
reidx.addSelectFieldname("outboundlinks_text_words_val");
reidx.addSelectFieldname("outboundlinks_alttag_txt");
}
sb.deployThread("reindexSolr", "Reindex Solr", "reindex documents with obsolete fields in embedded Solr index", "/IndexReIndexMonitor_p.html",reidx , 0);
sb.deployThread(ReindexSolrBusyThread.THREAD_NAME, "Reindex Solr", "reindex documents with obsolete fields in embedded Solr index", "/IndexReIndexMonitor_p.html",reidx , 0);
return 0;
}
}

@ -53,6 +53,8 @@ import org.apache.solr.common.SolrInputDocument;
*/
public class ReindexSolrBusyThread extends AbstractBusyThread {
public final static String THREAD_NAME = "reindexSolr";
SolrConnector esc;
final CollectionConfiguration colcfg; // collection config
int processed = 0; // total number of reindexed documents
@ -71,14 +73,14 @@ import org.apache.solr.common.SolrInputDocument;
this.esc = Switchboard.getSwitchboard().index.fulltext().getDefaultConnector();
this.colcfg = Switchboard.getSwitchboard().index.fulltext().getDefaultConfiguration();
if (Switchboard.getSwitchboard().getThread("reindexSolr") != null) {
if (Switchboard.getSwitchboard().getThread(ReindexSolrBusyThread.THREAD_NAME) != null) {
this.interrupt(); // only one active reindex job should exist
} else {
if (query != null) {
this.querylist.set(query, 0);
}
}
setName("reindexSolr");
setName(ReindexSolrBusyThread.THREAD_NAME);
this.setPriority(Thread.MIN_PRIORITY);
}
@ -154,7 +156,7 @@ import org.apache.solr.common.SolrInputDocument;
}
if (querylist.isEmpty()) { // if all processed remove from scheduled list (and terminate thread)
Switchboard.getSwitchboard().terminateThread("reindexSolr", false);
Switchboard.getSwitchboard().terminateThread(ReindexSolrBusyThread.THREAD_NAME, false);
ret = false;
}
return ret;

@ -468,9 +468,9 @@ public class serverSwitch {
threadMonitorURL,
newThread,
startupDelay,
Long.parseLong(getConfig(threadName + "_idlesleep", "100")),
Long.parseLong(getConfig(threadName + "_busysleep", "1000")),
Long.parseLong(getConfig(threadName + "_memprereq", "1000000")),
Long.parseLong(getConfig(threadName + "_idlesleep", "1000")),
Long.parseLong(getConfig(threadName + "_busysleep", "100")),
Long.parseLong(getConfig(threadName + "_memprereq", "1048576")),
Double.parseDouble(getConfig(threadName + "_loadprereq", "9.0")));
}

Loading…
Cancel
Save