Enforced controls (HTTP method, token) on ReIndex and ReCrawl operations

pull/154/head
luccioman 7 years ago
parent 36e9b1c5b3
commit fab6e54fec

@ -12,6 +12,7 @@
<p>In case that an index schema of the embedded/local index has changed, all documents with missing field entries can be indexed again with a reindex job.</p> <p>In case that an index schema of the embedded/local index has changed, all documents with missing field entries can be indexed again with a reindex job.</p>
<form action="IndexReIndexMonitor_p.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8"> <form action="IndexReIndexMonitor_p.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
<table><tr valign="top"><td> <table><tr valign="top"><td>
<input type="hidden" name="transactionToken" value="#[transactionToken]#"/>
<fieldset> <fieldset>
<table> <table>
<tr> <tr>
@ -62,6 +63,7 @@
This runs transparent as background job. Documents are added to the crawler only if no other crawls are active This runs transparent as background job. Documents are added to the crawler only if no other crawls are active
and are added in small chunks.</p> and are added in small chunks.</p>
<form action="IndexReIndexMonitor_p.html?setup=recrawljob" method="post" enctype="multipart/form-data" accept-charset="UTF-8"> <form action="IndexReIndexMonitor_p.html?setup=recrawljob" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
<input type="hidden" name="transactionToken" value="#[transactionToken]#" />
<table><tr valign="top"><td> <table><tr valign="top"><td>
<fieldset> <fieldset>

@ -22,7 +22,7 @@ import net.yacy.cora.sorting.OrderedScoreMap;
import net.yacy.kelondro.workflow.BusyThread; import net.yacy.kelondro.workflow.BusyThread;
import net.yacy.migration; import net.yacy.migration;
import net.yacy.crawler.RecrawlBusyThread; import net.yacy.crawler.RecrawlBusyThread;
import net.yacy.data.TransactionManager;
import net.yacy.search.Switchboard; import net.yacy.search.Switchboard;
import net.yacy.search.index.ReindexSolrBusyThread; import net.yacy.search.index.ReindexSolrBusyThread;
import net.yacy.server.serverObjects; import net.yacy.server.serverObjects;
@ -34,12 +34,19 @@ public class IndexReIndexMonitor_p {
final Switchboard sb = (Switchboard) env; final Switchboard sb = (Switchboard) env;
final serverObjects prop = new serverObjects(); final serverObjects prop = new serverObjects();
/* Acquire a transaction token for the next possible POST form submissions */
final String nextTransactionToken = TransactionManager.getTransactionToken(header);
prop.put(TransactionManager.TRANSACTION_TOKEN_PARAM, nextTransactionToken);
prop.put("docsprocessed", "0"); prop.put("docsprocessed", "0");
prop.put("currentselectquery",""); prop.put("currentselectquery","");
BusyThread reidxbt = sb.getThread(ReindexSolrBusyThread.THREAD_NAME); BusyThread reidxbt = sb.getThread(ReindexSolrBusyThread.THREAD_NAME);
if (reidxbt == null) { if (reidxbt == null) {
if (post != null && post.containsKey("reindexnow") && sb.index.fulltext().connectedLocalSolr()) { if (post != null && post.containsKey("reindexnow") && sb.index.fulltext().connectedLocalSolr()) {
/* Check the transaction is valid */
TransactionManager.checkPostTransaction(header, post);
migration.reindexToschema(sb); migration.reindexToschema(sb);
prop.put("querysize", "0"); prop.put("querysize", "0");
prop.put("infomessage","reindex job started"); prop.put("infomessage","reindex job started");
@ -71,6 +78,9 @@ public class IndexReIndexMonitor_p {
} }
if (post != null && post.containsKey("stopreindex")) { if (post != null && post.containsKey("stopreindex")) {
/* Check the transaction is valid */
TransactionManager.checkPostTransaction(header, post);
sb.terminateThread(ReindexSolrBusyThread.THREAD_NAME, false); sb.terminateThread(ReindexSolrBusyThread.THREAD_NAME, false);
prop.put("infomessage", "reindex job stopped"); prop.put("infomessage", "reindex job stopped");
prop.put("reindexjobrunning",0); prop.put("reindexjobrunning",0);
@ -93,6 +103,9 @@ public class IndexReIndexMonitor_p {
// to signal that a setting shall change the form provides a fixed parameter setup=recrawljob, if not present return status only // to signal that a setting shall change the form provides a fixed parameter setup=recrawljob, if not present return status only
if (post != null && "recrawljob".equals(post.get("setup"))) { // it's a command to recrawlThread if (post != null && "recrawljob".equals(post.get("setup"))) { // it's a command to recrawlThread
/* Check the transaction is valid */
TransactionManager.checkPostTransaction(header, post);
if (recrawlbt == null) { if (recrawlbt == null) {
if (post.containsKey("recrawlnow") && sb.index.fulltext().connectedLocalSolr()) { if (post.containsKey("recrawlnow") && sb.index.fulltext().connectedLocalSolr()) {

@ -60,6 +60,7 @@
</form> </form>
<p><br /></p> <p><br /></p>
<form action="IndexReIndexMonitor_p.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8"> <form action="IndexReIndexMonitor_p.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
<input type="hidden" name="transactionToken" value="#[IndexReIndex_transactionToken]#"/>
<fieldset> <fieldset>
<legend><label>Reindex documents</label></legend> <legend><label>Reindex documents</label></legend>
<p>If you unselected some fields, old documents in the index still contain the unselected fields. <p>If you unselected some fields, old documents in the index still contain the unselected fields.

@ -26,6 +26,7 @@ import net.yacy.cora.federate.solr.SchemaConfiguration;
import net.yacy.cora.federate.solr.SchemaDeclaration; import net.yacy.cora.federate.solr.SchemaDeclaration;
import net.yacy.cora.protocol.RequestHeader; import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.util.ConcurrentLog; import net.yacy.cora.util.ConcurrentLog;
import net.yacy.data.TransactionManager;
import net.yacy.search.Switchboard; import net.yacy.search.Switchboard;
import net.yacy.search.schema.CollectionSchema; import net.yacy.search.schema.CollectionSchema;
import net.yacy.search.schema.WebgraphConfiguration; import net.yacy.search.schema.WebgraphConfiguration;
@ -39,7 +40,7 @@ public class IndexSchema_p {
// return variable that accumulates replacements // return variable that accumulates replacements
final serverObjects prop = new serverObjects(); final serverObjects prop = new serverObjects();
final Switchboard sb = (Switchboard) env; final Switchboard sb = (Switchboard) env;
String schemaName = CollectionSchema.CORE_NAME; String schemaName = CollectionSchema.CORE_NAME;
if (post != null) schemaName = post.get("core", schemaName); if (post != null) schemaName = post.get("core", schemaName);
SchemaConfiguration cs = schemaName.equals(CollectionSchema.CORE_NAME) ? sb.index.fulltext().getDefaultConfiguration() : sb.index.fulltext().getWebgraphConfiguration(); SchemaConfiguration cs = schemaName.equals(CollectionSchema.CORE_NAME) ? sb.index.fulltext().getDefaultConfiguration() : sb.index.fulltext().getWebgraphConfiguration();
@ -101,6 +102,10 @@ public class IndexSchema_p {
} }
} }
/* Acquire a transaction token for the next possible POST IndexReIndeMonitor_p form submission */
prop.put("IndexReIndex_" + TransactionManager.TRANSACTION_TOKEN_PARAM,
TransactionManager.getTransactionToken(header, "/IndexReIndexMonitor_p.html"));
int c = 0; int c = 0;
boolean dark = false; boolean dark = false;
// use enum SolrField to keep defined order // use enum SolrField to keep defined order

Loading…
Cancel
Save