Merge remote-tracking branch 'choose_remote_name/master'

pull/38/head
sixcooler 9 years ago
commit dce1cb65c4

@ -702,6 +702,12 @@
<jvmarg line="-Xnoagent"/>
<jvmarg line="-Djava.compiler=none"/>
<jvmarg line="-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y"/>
<!-- Dump memory heap when an OutOfMemoryError occurs -->
<!-- <jvmarg line="-XX:+HeapDumpOnOutOfMemoryError"/> -->
<!-- Dump path -->
<!-- <jvmarg line="-XX:HeapDumpPath=/your_path/"/> -->
<!-- Log JAXP XML parsers Debug information -->
<!-- <jvmarg line="-Djaxp.debug=1"/> -->
</java>
</target>

@ -111,7 +111,9 @@
</fields>
<uniqueKey>id</uniqueKey>
<!-- defaultSearchField element is deprecated in Solr versions 3.6 and higher. Instead, df request parameter should be used-->
<defaultSearchField>text_t</defaultSearchField>
<!-- default operator parameter has been deprecated in Solr versions 3.6 and higher. Instead, the query parser q.op parameter should be used in request handler. -->
<solrQueryParser defaultOperator="AND"/>
<!-- if you are using a search client using the default search field "text", then use this line to get to all indexed documents -->

@ -873,6 +873,8 @@ search.verify.delete = true
remotesearch.maxcount = 10
remotesearch.maxtime = 3000
remotesearch.result.store=true
# Maximum size allowed (in bytes) for a remote document result to be stored to local index. Defaults to -1, which means no limit.
remotesearch.result.store.maxsize=-1
remotesearch.maxload.rwi=8.0
remotesearch.maxload.solr=4.0

@ -66,7 +66,11 @@
<dt>Index remote results</dt>
<dd>
<input type="checkbox" name="remotesearch.result.store" value="true" #(remotesearch.result.store)#::checked="checked"#(/remotesearch.result.store)# /> add remote search results to the local index <b>( default=on, it is recommended to enable this option ! )</b>
<input type="checkbox" name="remotesearch.result.store" value="true" #(remotesearch.result.store)#::checked="checked"#(/remotesearch.result.store)# /> add remote search results to the local index <b>( default=on, it is recommended to enable this option ! )</b>
</dd>
<dt>Limit size of indexed remote results</dt>
<dd>
<input type="text" name="remotesearch.result.store.maxsize" value="#[remotesearch.result.store.maxsize]#" size="10" /> maximum allowed size in kbytes for each remote search result to be added to the local index (for example, a 1000kbytes limit might be useful if you are running YaCy with a low memory setup)
</dd>
<dt>Default Pop-Up Page</dt>
@ -142,7 +146,7 @@
</pre></fieldset>
This would look like:
<iframe name="target"
src="http://#[myaddress]#/index.html?display=2&amp;resource=local&amp;focus=0"
src="http://#[myPreviewAddress]#/index.html?display=2&amp;resource=local&amp;focus=0"
width="100%"
height="410"
frameborder="0"
@ -165,7 +169,7 @@
</pre></fieldset>
This would look like:
<iframe name="target2"
src="http://#[myaddress]#/yacysearch.html?display=2&amp;resource=local&amp;focus=0"
src="http://#[myPreviewAddress]#/yacysearch.html?display=2&amp;resource=local&amp;focus=0"
width="100%"
height="180"
frameborder="0"
@ -189,7 +193,7 @@
</pre></fieldset>
This would look like:
<iframe name="target3"
src="http://#[myaddress]#/yacyinteractive.html?display=2&amp;focus=0"
src="http://#[myPreviewAddress]#/yacyinteractive.html?display=2&amp;focus=0"
width="100%"
height="180"
frameborder="0"

@ -93,6 +93,7 @@ public class ConfigPortal {
final boolean storeresult = post.getBoolean(SwitchboardConstants.REMOTESEARCH_RESULT_STORE);
sb.setConfig(SwitchboardConstants.REMOTESEARCH_RESULT_STORE, storeresult);
sb.setConfig(SwitchboardConstants.REMOTESEARCH_RESULT_STORE_MAXSIZE, post.getLong(SwitchboardConstants.REMOTESEARCH_RESULT_STORE_MAXSIZE, -1));
sb.setConfig(SwitchboardConstants.SEARCH_VERIFY, post.get("search.verify", "ifexist"));
sb.setConfig(SwitchboardConstants.SEARCH_VERIFY_DELETE, post.getBoolean("search.verify.delete"));
@ -148,6 +149,7 @@ public class ConfigPortal {
sb.setConfig("search.options", config.getProperty("search.options","true"));
sb.setConfig(SwitchboardConstants.GREEDYLEARNING_ACTIVE, config.getProperty(SwitchboardConstants.GREEDYLEARNING_ACTIVE));
sb.setConfig(SwitchboardConstants.REMOTESEARCH_RESULT_STORE, config.getProperty(SwitchboardConstants.REMOTESEARCH_RESULT_STORE));
sb.setConfig(SwitchboardConstants.REMOTESEARCH_RESULT_STORE_MAXSIZE, config.getProperty(SwitchboardConstants.REMOTESEARCH_RESULT_STORE_MAXSIZE));
sb.setConfig(SwitchboardConstants.SEARCH_VERIFY, config.getProperty(SwitchboardConstants.SEARCH_VERIFY,"iffresh"));
sb.setConfig(SwitchboardConstants.SEARCH_VERIFY_DELETE, config.getProperty(SwitchboardConstants.SEARCH_VERIFY_DELETE,"true"));
sb.setConfig("about.headline", config.getProperty("about.headline",""));
@ -170,6 +172,12 @@ public class ConfigPortal {
prop.put(SwitchboardConstants.GREEDYLEARNING_LIMIT_DOCCOUNT, sb.getConfig(SwitchboardConstants.GREEDYLEARNING_LIMIT_DOCCOUNT, "0"));
prop.put(SwitchboardConstants.REMOTESEARCH_RESULT_STORE, sb.getConfigBool(SwitchboardConstants.REMOTESEARCH_RESULT_STORE, true) ? 1 : 0);
long resultStoredMaxSize = sb.getConfigLong(SwitchboardConstants.REMOTESEARCH_RESULT_STORE_MAXSIZE, -1);
if(resultStoredMaxSize > 0) {
prop.put(SwitchboardConstants.REMOTESEARCH_RESULT_STORE_MAXSIZE, resultStoredMaxSize);
} else {
prop.put(SwitchboardConstants.REMOTESEARCH_RESULT_STORE_MAXSIZE, "");
}
prop.put("search.verify.nocache", sb.getConfig("search.verify", "").equals("nocache") ? 1 : 0);
prop.put("search.verify.iffresh", sb.getConfig("search.verify", "").equals("iffresh") ? 1 : 0);
@ -216,11 +224,19 @@ public class ConfigPortal {
prop.put("target_selected_special_searchresult", "searchresult".equals(target_special) ? 1 : 0);
prop.put("target_special_pattern", sb.getConfig(SwitchboardConstants.SEARCH_TARGET_SPECIAL_PATTERN, ""));
/* Addresse used in code template */
String myaddress = (sb.peers == null) || sb.peers.mySeed() == null || sb.peers.mySeed().getIP() == null ? null : sb.peers.mySeed().getPublicAddress(sb.peers.mySeed().getIP());
if (myaddress == null) {
myaddress = "localhost:" + sb.getLocalPort();
}
prop.put("myaddress", myaddress);
/* Adress used to display iframe preview : no need to use public adress when coming from local */
String myPreviewAddress = myaddress;
if(header.accessFromLocalhost()) {
myPreviewAddress = "localhost:" + sb.getLocalPort();
}
prop.put("myPreviewAddress", myPreviewAddress);
return prop;
}

@ -69,7 +69,9 @@
</fields>
<uniqueKey>#[solruniquekey]#</uniqueKey>
<!-- defaultSearchField element is deprecated in Solr versions 3.6 and higher. Instead, df request parameter should be used-->
<defaultSearchField>#[solrdefaultsearchfield]#</defaultSearchField>
<!-- default operator parameter has been deprecated in Solr versions 3.6 and higher. Instead, the query parser q.op parameter should be used in request handler. -->
<solrQueryParser defaultOperator="AND"/>
<!-- if you are using a search client using the default search field "text", then use this line to get to all indexed documents -->

@ -27,6 +27,8 @@ package net.yacy.kelondro.util;
import java.util.concurrent.atomic.AtomicBoolean;
import net.yacy.cora.util.ConcurrentLog;
/**
* Use this to get information about memory usage or try to free some memory
*/
@ -183,33 +185,54 @@ public class MemoryControl {
* main
* @param args use 'force' to request by force, use 'std' / 'gen' to specify strategy
*/
public static void main(final String[] args) {
// try this with different strategy and compare results
final int mb = 1024 * 1024;
boolean force = false;
for (final String arg : args) {
if (arg.equals("force")) force = true;
if (arg.equalsIgnoreCase("gen")) usingStandardStrategy = false;
if (arg.equalsIgnoreCase("std")) usingStandardStrategy = true;
}
System.out.println("vm: " + System.getProperty("java.vm.version"));
System.out.println("computed max = " + (maxMemory() / mb) + " mb");
System.out.println("using " + getStrategyName());
final byte[][] x = new byte[100000][];
for (int i = 0; i < 100000; i++) {
if (request(mb, force))
{
x[i] = new byte[mb];
System.out.println("used = " + i + " / " + (used() /mb) +
", total = " + (total() / mb) +
", free = " + (free() / mb) +
", max = " + (maxMemory() / mb) +
", avail = " + (available() / mb) +
(usingStandardStrategy? ", averageGC = " + ((StandardMemoryStrategy)getStrategy()).getAverageGCFree() : ""));
} else System.exit(0);
}
public static void main(final String[] args) {
long beginTime = System.nanoTime();
int i = 0;
try {
// try this with different strategy and compare results
final int mb = 1024 * 1024;
boolean force = false;
for (final String arg : args) {
if (arg.equals("force"))
force = true;
if (arg.equalsIgnoreCase("gen"))
usingStandardStrategy = false;
if (arg.equalsIgnoreCase("std"))
usingStandardStrategy = true;
}
System.out.println("vm: " + System.getProperty("java.vm.version"));
System.out.println("computed max = " + (maxMemory() / mb) + " mb");
System.out.println("using " + getStrategyName());
if(force) {
System.out.println("forcing garbage collector when requesting");
} else {
System.out.println("not forcing garbage collector when requesting");
}
final byte[][] x = new byte[100000][];
for (i = 0; i < 100000; i++) {
if (request(mb, force)) {
x[i] = new byte[mb];
System.out
.println("used = " + i + " / " + (used() / mb) + ", total = " + (total() / mb) + ", free = "
+ (free() / mb) + ", max = " + (maxMemory() / mb) + ", avail = "
+ (available() / mb)
+ (usingStandardStrategy
? ", averageGC = "
+ ((StandardMemoryStrategy) getStrategy()).getAverageGCFree()
: ""));
} else {
System.out.println("No more memory available!");
break;
}
}
} finally {
long time = System.nanoTime() - beginTime;
System.out.println("Test run in " + time / 1000000 + " ms");
ConcurrentLog.shutdown();
System.out.println("Succesfull requests : " + i);
}
}
}
}

@ -60,8 +60,18 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.http.entity.mime.content.ContentBody;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.response.FacetField;
import org.apache.solr.client.solrj.response.FacetField.Count;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;
import net.yacy.migration;
import net.yacy.cora.date.GenericFormatter;
import net.yacy.cora.document.analysis.Classification;
@ -120,15 +130,6 @@ import net.yacy.server.serverObjects;
import net.yacy.server.serverSwitch;
import net.yacy.utils.crypt;
import org.apache.http.entity.mime.content.ContentBody;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.response.FacetField;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.client.solrj.response.FacetField.Count;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;
public final class Protocol {
@ -487,7 +488,7 @@ public final class Protocol {
final int partitions,
final Seed target,
final SecondarySearchSuperviser secondarySearchSuperviser,
final Blacklist blacklist) {
final Blacklist blacklist) throws InterruptedException {
// send a search request to peer with remote Hash
// INPUT:
@ -586,7 +587,7 @@ public final class Protocol {
final int maxDistance,
final int partitions,
final Seed target,
final Blacklist blacklist) {
final Blacklist blacklist) throws InterruptedException {
final long timestamp = System.currentTimeMillis();
event.addExpectedRemoteReferences(count);
@ -639,7 +640,7 @@ public final class Protocol {
final Seed target,
final Blacklist blacklist,
final SearchResult result
) throws SpaceExceededException {
) throws SpaceExceededException, InterruptedException {
// create containers
final int words = wordhashes.length() / Word.commonHashLength;
@ -745,14 +746,24 @@ public final class Protocol {
// insert one container into the search result buffer
// one is enough, only the references are used, not the word
if (event.addResultsToLocalIndex) {
for (URIMetadataNode entry : storeDocs) {
try {
event.query.getSegment().setFirstSeenTime(entry.hash(), Math.min(entry.moddate().getTime(), System.currentTimeMillis()));
event.query.getSegment().fulltext().putMetadata(entry); // it will be checked inside the putMetadata that poor metadata does not overwrite rich metadata
} catch (final IOException e) {
ConcurrentLog.logException(e);
}
}
/*
* Current thread might be interrupted by SearchEvent.cleanup()
*/
if (Thread.interrupted()) {
throw new InterruptedException("solrQuery interrupted");
}
WriteMetadataNodeToLocalIndexThread writerToLocalIndex = new WriteMetadataNodeToLocalIndexThread(event.query.getSegment(), storeDocs);
writerToLocalIndex.start();
try {
writerToLocalIndex.join();
} catch(InterruptedException e) {
/*
* Current thread interruption might happen while waiting
* for writeToLocalIndexThread.
*/
writerToLocalIndex.stopWriting();
throw new InterruptedException("remoteProcess stopped!");
}
event.addRWIs(container.get(0), false, target.getName() + "/" + target.hash, result.totalCount, time);
} else {
// feed results as nodes (SolrQuery results) which carry metadata,
@ -783,6 +794,56 @@ public final class Protocol {
}
Network.log.info("remote search: peer " + target.getName() + " sent " + container.get(0).size() + "/" + result.totalCount + " references");
}
/**
* This thread is used to write a collection of URIMetadataNode documents to a segment allowing to be safely stopped.
* Indeed, if one interrupt a thread while commiting to Solr index, the index is closed and will be no more writable
* (later calls would throw a org.apache.lucene.store.AlreadyClosedException) because Solr IndexWriter uses an InterruptibleChanel.
* This thread allow to safely stop writing operation using an AtomicBoolean.
* @author luc
*
*/
private static class WriteMetadataNodeToLocalIndexThread extends Thread {
private AtomicBoolean stop = new AtomicBoolean(false);
private Segment segment;
private Collection<URIMetadataNode> storeDocs;
/**
* Parameters must be not null.
* @param segment solr segment to write
* @param storeDocs solr documents collection to put to segment
*/
public WriteMetadataNodeToLocalIndexThread(Segment segment, Collection<URIMetadataNode> storeDocs) {
this.segment = segment;
this.storeDocs = storeDocs;
}
/**
* Use this to stop writing operation. This thread will not stop immediately as Solr might be writing something.
*/
public void stopWriting() {
this.stop.set(true);
}
@Override
public void run() {
for (URIMetadataNode entry : this.storeDocs) {
if(stop.get()) {
Network.log.info("Writing documents collection to Solr segment was stopped.");
return;
}
try {
segment.setFirstSeenTime(entry.hash(), Math.min(entry.moddate().getTime(), System.currentTimeMillis()));
segment.fulltext().putMetadata(entry); // it will be checked inside the putMetadata that poor metadata does not overwrite rich metadata
} catch (final IOException e) {
ConcurrentLog.logException(e);
}
}
}
}
private static class SearchResult {
public int availableCount; // number of returned LURL's for this search
@ -929,6 +990,18 @@ public final class Protocol {
private final static CollectionSchema[] snippetFields = new CollectionSchema[]{CollectionSchema.description_txt, CollectionSchema.h4_txt, CollectionSchema.h3_txt, CollectionSchema.h2_txt, CollectionSchema.h1_txt, CollectionSchema.text_t};
/**
* Execute solr query against specified target.
* @param event search event ot feed with results
* @param solrQuery solr query
* @param offset pagination start indice
* @param count expected maximum results
* @param target target peer to query. May be null : in that case, local peer is queried.
* @param partitions
* @param blacklist url list to exclude from results
* @return the size of results list
* @throws InterruptedException when interrupt status on calling thread is detected while processing
*/
protected static int solrQuery(
final SearchEvent event,
final SolrQuery solrQuery,
@ -936,7 +1009,7 @@ public final class Protocol {
final int count,
final Seed target,
final int partitions,
final Blacklist blacklist) {
final Blacklist blacklist) throws InterruptedException {
//try {System.out.println("*** debug-query *** " + URLDecoder.decode(solrQuery.toString(), "UTF-8"));} catch (UnsupportedEncodingException e) {}
@ -1125,12 +1198,17 @@ public final class Protocol {
// put the remote documents to the local index. We must convert the solr document to a solr input document:
if (event.addResultsToLocalIndex) {
final SolrInputDocument sid = event.query.getSegment().fulltext().getDefaultConfiguration().toSolrInputDocument(doc);
// the input document stays untouched because it contains top-level cloned objects
docs.add(sid);
// will be stored to index, and is a full solr document, can be added to firstseen
event.query.getSegment().setFirstSeenTime(urlEntry.hash(), Math.min(urlEntry.moddate().getTime(), System.currentTimeMillis()));
/* Check document size, only if a limit is set on remote documents size allowed to be stored to local index */
if(checkDocumentSize(doc, event.getRemoteDocStoredMaxSize() * 1024)) {
final SolrInputDocument sid = event.query.getSegment().fulltext().getDefaultConfiguration().toSolrInputDocument(doc);
// the input document stays untouched because it contains top-level cloned objects
docs.add(sid);
// will be stored to index, and is a full solr document, can be added to firstseen
event.query.getSegment().setFirstSeenTime(urlEntry.hash(), Math.min(urlEntry.moddate().getTime(), System.currentTimeMillis()));
} else {
Network.log.info("Document size greater than " + event.getRemoteDocStoredMaxSize() + " kbytes, excludes it from being stored to local index. Url : " + urlEntry.urlstring());
}
}
// after this conversion we can remove the largest and not used field text_t and synonyms_sxt from the document
@ -1160,10 +1238,26 @@ public final class Protocol {
Network.log.info("local search (solr): localpeer sent " + container.size() + "/" + numFound + " references");
} else {
if (event.addResultsToLocalIndex) {
for (SolrInputDocument doc: docs) {
event.query.getSegment().putDocument(doc);
}
docs.clear(); docs = null;
/*
* Current thread might be interrupted by SearchEvent.cleanup()
*/
if (Thread.interrupted()) {
throw new InterruptedException("solrQuery interrupted");
}
WriteToLocalIndexThread writeToLocalIndexThread = new WriteToLocalIndexThread(event.query.getSegment(),
docs);
writeToLocalIndexThread.start();
try {
writeToLocalIndexThread.join();
} catch (InterruptedException e) {
/*
* Current thread interruption might happen while waiting
* for writeToLocalIndexThread.
*/
writeToLocalIndexThread.stopWriting();
throw new InterruptedException("solrQuery interrupted");
}
docs.clear();
}
event.addNodes(container, facets, snippets, false, target.getName() + "/" + target.hash, numFound);
event.addFinalize();
@ -1172,6 +1266,78 @@ public final class Protocol {
}
return dls;
}
/**
* This thread is used to write a collection of Solr documents to a segment allowing to be safely stopped.
* Indeed, if one interrupt a thread while commiting to Solr index, the index is closed and will be no more writable
* (later calls would throw a org.apache.lucene.store.AlreadyClosedException) because Solr IndexWriter uses an InterruptibleChanel.
* This thead allow to safely stop writing operation using an AtomicBoolean.
* @author luc
*
*/
private static class WriteToLocalIndexThread extends Thread {
private AtomicBoolean stop = new AtomicBoolean(false);
private Segment segment;
private Collection<SolrInputDocument> docs;
/**
* Parameters must be not null.
* @param segment solr segment to write
* @param docs solr documents collection to put to segment
*/
public WriteToLocalIndexThread(Segment segment, Collection<SolrInputDocument> docs) {
this.segment = segment;
this.docs = docs;
}
/**
* Use this to stop writing operation. This thread will not stop immediately as Solr might be writing something.
*/
public void stopWriting() {
this.stop.set(true);
}
@Override
public void run() {
for (SolrInputDocument doc: docs) {
if(stop.get()) {
Network.log.info("Writing documents collection to Solr segment was stopped.");
return;
}
segment.putDocument(doc);
}
}
}
/**
* Only when maxSize is greater than zero, check that doc size is lower. To
* process in a reasonable amount of time, document size is not evaluated
* summing all fields sizes, but only against text_t field which is quite representative and might weigh
* some MB.
*
* @param doc
* document to verify. Must not be null.
* @param maxSize
* maximum allowed size in bytes
* @return true when document evaluated size is lower or equal than maxSize, or when
* maxSize is lower or equal than zero.
*/
protected static boolean checkDocumentSize(SolrDocument doc, long maxSize) {
if (maxSize > 0) {
/* All text field is often the largest */
Object value = doc.getFieldValue(CollectionSchema.text_t.getSolrFieldName());
if(value instanceof String) {
/* Each char uses 2 bytes */
if(((String)value).length() > (maxSize /2)) {
return false;
}
}
}
return true;
}
public static Map<String, String> permissionMessage(final String targetAddress, final String targetHash) {
// ask for allowed message size and attachment size

@ -121,6 +121,8 @@ public class RemoteSearch extends Thread {
} else {
Network.log.info("REMOTE SEARCH - no answer from remote peer " + this.targetPeer.hash + ":" + this.targetPeer.getName());
}
} catch(InterruptedException e) {
Network.log.info("REMOTE SEARCH - interrupted search to remote peer " + this.targetPeer.hash + ":" + this.targetPeer.getName());
} catch (final Exception e) {
ConcurrentLog.logException(e);
} finally {
@ -309,6 +311,8 @@ public class RemoteSearch extends Thread {
} else {
Network.log.info("REMOTE SEARCH - no answer from remote peer " + targetPeer.hash + ":" + targetPeer.getName());
}
} catch (final InterruptedException e) {
Network.log.info("REMOTE SEARCH - interrupted search to remote peer " + targetPeer.hash + ":" + targetPeer.getName());
} catch (final Exception e) {
ConcurrentLog.logException(e);
} finally {
@ -359,6 +363,8 @@ public class RemoteSearch extends Thread {
Network.log.info("REMOTE SEARCH - no answer from remote peer " + targetPeer.hash + ":" + targetPeer.getName());
}
}
} catch (final InterruptedException e) {
Network.log.info("REMOTE SEARCH - interrupted search to remote peer " + targetPeer.hash + ":" + targetPeer.getName());
} catch (final Exception e) {
ConcurrentLog.logException(e);
} finally {

@ -332,6 +332,8 @@ public final class SwitchboardConstants {
public static final String REMOTESEARCH_MAXCOUNT_USER = "remotesearch.maxcount";
public static final String REMOTESEARCH_MAXTIME_USER = "remotesearch.maxtime";
public static final String REMOTESEARCH_RESULT_STORE = "remotesearch.result.store"; // add remote results to local index
/** Maximum size allowed (in kbytes) for a remote document result to be stored to local index */
public static final String REMOTESEARCH_RESULT_STORE_MAXSIZE= "remotesearch.result.store.maxsize";
public static final String REMOTESEARCH_MAXLOAD_RWI = "remotesearch.maxload.rwi";
public static final String REMOTESEARCH_MAXLOAD_SOLR = "remotesearch.maxload.solr";

@ -161,6 +161,8 @@ public final class SearchEvent {
private ConcurrentHashMap<String, LinkedHashSet<String>> snippets;
private final boolean remote;
public final boolean addResultsToLocalIndex; // add received results to local index (defult=true)
/** Maximum size allowed (in kbytes) for a remote document result to be stored to local index */
private long remoteStoredDocMaxSize;
private SortedMap<byte[], ReferenceContainer<WordReference>> localSearchInclusion;
private final ScoreMap<String> ref; // reference score computation for the commonSense heuristic
private final long maxtime;
@ -198,6 +200,22 @@ public final class SearchEvent {
);
}
/**
* Set maximum size allowed (in kbytes) for a remote document result to be stored to local index.
* @param maxSize document content max size in kbytes. Zero or negative value means no limit.
*/
public void setRemoteDocStoredMaxSize(long maxSize) {
this.remoteStoredDocMaxSize = maxSize;
}
/**
* @return maximum size allowed (in kbytes) for a remote document result to be stored to local index.
* Zero or negative value means no limit.
*/
public long getRemoteDocStoredMaxSize() {
return this.remoteStoredDocMaxSize;
}
protected SearchEvent(
final QueryParams query,
final SeedDB peers,
@ -261,6 +279,8 @@ public final class SearchEvent {
this.IAneardhthash = null;
this.remote = (peers != null && peers.sizeConnected() > 0) && (this.query.domType == QueryParams.Searchdom.CLUSTER || (this.query.domType == QueryParams.Searchdom.GLOBAL && Switchboard.getSwitchboard().getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, false)));
this.addResultsToLocalIndex = addResultsToLocalIdx;
/* Défault : no size limit to store remote result documents to local index. Use setter to eventually modify it. */
this.remoteStoredDocMaxSize = -1;
this.local_rwi_available = new AtomicInteger(0); // the number of results in the local peer after filtering
this.local_rwi_stored = new AtomicInteger(0);
this.local_solr_available = new AtomicInteger(0);

@ -174,6 +174,10 @@ public class SearchEventCache {
|| (sb.getConfigBool(SwitchboardConstants.NETWORK_SEARCHVERIFY, false) && sb.peers.mySeed().getFlagAcceptRemoteIndex());
final boolean addToLocalIdx = sb == null || Switchboard.getSwitchboard().getConfigBool(SwitchboardConstants.REMOTESEARCH_RESULT_STORE, true);
event = new SearchEvent(query, peers, workTables, preselectedPeerHashes, generateAbstracts, loader, remote_maxcount, remote_maxtime, delete, addToLocalIdx);
/* Optional config option may be valued to limit size of remote documents added to local index */
if(sb != null) {
event.setRemoteDocStoredMaxSize(sb.getConfigLong(SwitchboardConstants.REMOTESEARCH_RESULT_STORE_MAXSIZE, -1));
}
MemoryControl.request(100 * 1024 * 1024, false); // this may trigger a short memory status which causes a reducing of cache space of other threads
}

Loading…
Cancel
Save