Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
fixes https://github.com/yacy/yacy_search_server/issues/424
Michael Peter Christenbe0aebad8481
diff --git a/defaults/yacy.init b/defaults/yacy.initindex 67a51126d..25ede5a9b 100644--- a/defaults/yacy.init+++ b/defaults/yacy.init@@ -526,8 +526,9 @@ seedScpPassword=seedScpPath=# every peer periodically scans for other peers. you can set the time-# of the period here (minutes)-peerCycle=2+# of the period here (minutes). You might switch it on in kubernetes clusters+scan.enabled=false+scan.peerCycle=2# debug flagsdebug.search.local.dht.off=falsediff --git a/source/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnector.java b/source/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnector.javaindex d0a10ac72..5d317a0be 100644--- a/source/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnector.java+++ b/source/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnector.java@@ -71,7 +71,7 @@ import net.yacy.cora.util.ConcurrentLog;import net.yacy.search.schema.CollectionSchema;public class EmbeddedSolrConnector extends SolrServerConnector implements SolrConnector {-+public static final String SELECT = "/select";public static final String CONTEXT = "/solr";@@ -85,20 +85,20 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCothis.instance = instance;this.core = this.instance.getDefaultCore();this.requestHandler = new SearchHandler();- this.requestHandler.init(new NamedList<Object>());+ this.requestHandler.init(new NamedList<>());this.requestHandler.inform(this.core);//this.suggestHandler = new SuggestComponent();//this.suggestHandler.init(new NamedList<Object>());//this.suggestHandler.inform(this.core);super.init(this.instance.getDefaultServer());}-+public EmbeddedSolrConnector(EmbeddedInstance instance, String coreName) {super();this.instance = instance;this.core = this.instance.getCore(coreName);this.requestHandler = new SearchHandler();- this.requestHandler.init(new NamedList<Object>());+ this.requestHandler.init(new NamedList<>());this.requestHandler.inform(this.core);//this.suggestHandler = new SuggestComponent();//this.suggestHandler.init(new NamedList<Object>());@@ -110,12 +110,12 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCopublic int hashCode() {return this.instance.hashCode();}-+@Overridepublic boolean equals(Object o) {return o instanceof EmbeddedSolrConnector && this.instance.equals(((EmbeddedSolrConnector) o).instance);}-+@Overridepublic int bufferSize() {return 0;@@ -123,25 +123,29 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo@Overridepublic void clearCaches() {- SolrConfig solrConfig = this.core.getSolrConfig();+ final SolrConfig solrConfig = this.core.getSolrConfig();@SuppressWarnings("unchecked")+ finalSolrCache<String, ?> fieldValueCache = solrConfig.fieldValueCacheConfig == null ? null : solrConfig.fieldValueCacheConfig.newInstance();if (fieldValueCache != null) fieldValueCache.clear();@SuppressWarnings("unchecked")+ finalSolrCache<Query, DocSet> filterCache= solrConfig.filterCacheConfig == null ? null : solrConfig.filterCacheConfig.newInstance();if (filterCache != null) filterCache.clear();@SuppressWarnings("unchecked")+ finalSolrCache<QueryResultKey, DocList> queryResultCache = solrConfig.queryResultCacheConfig == null ? null : solrConfig.queryResultCacheConfig.newInstance();if (queryResultCache != null) queryResultCache.clear();@SuppressWarnings("unchecked")+ finalSolrCache<Integer, Document> documentCache = solrConfig.documentCacheConfig == null ? null : solrConfig.documentCacheConfig.newInstance();if (documentCache != null) documentCache.clear();}-+public SolrInstance getInstance() {return this.instance;}-+public SolrCore getCore() {return this.core;}@@ -154,7 +158,7 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCopublic boolean isClosed() {return this.core == null || this.core.isClosed();}-+@Overrideprotected void finalize() throws Throwable {this.close();@@ -171,10 +175,10 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo@Overridepublic long getSize() {- RefCounted<SolrIndexSearcher> refCountedIndexSearcher = this.core.getSearcher();- SolrIndexSearcher searcher = refCountedIndexSearcher.get();- DirectoryReader reader = searcher.getIndexReader();- long numDocs = reader.numDocs();+ final RefCounted<SolrIndexSearcher> refCountedIndexSearcher = this.core.getSearcher();+ final SolrIndexSearcher searcher = refCountedIndexSearcher.get();+ final DirectoryReader reader = searcher.getIndexReader();+ final long numDocs = reader.numDocs();refCountedIndexSearcher.decref();return numDocs;}@@ -185,23 +189,23 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo* @return*/public SolrQueryRequest request(final SolrParams params) {- SolrQueryRequest req = new SolrQueryRequestBase(this.core, params){};+ final SolrQueryRequest req = new SolrQueryRequestBase(this.core, params){};req.getContext().put("path", SELECT);req.getContext().put("webapp", CONTEXT);return req;}-+public SolrQueryResponse query(SolrQueryRequest req) throws SolrException {final long startTime = System.currentTimeMillis();// during the solr query we set the thread name to the query string to get more debugging info in thread dumps- String threadname = Thread.currentThread().getName();- String ql = ""; try {ql = URLDecoder.decode(req.getParams().toString(), StandardCharsets.UTF_8.name());} catch (UnsupportedEncodingException e) {}+ final String threadname = Thread.currentThread().getName();+ String ql = ""; try {ql = URLDecoder.decode(req.getParams().toString(), StandardCharsets.UTF_8.name());} catch (final UnsupportedEncodingException e) {}Thread.currentThread().setName("Embedded solr query: " + ql); // for debugging in ThreaddumpConcurrentLog.fine("EmbeddedSolrConnector.query", "QUERY: " + ql);-- SolrQueryResponse rsp = new SolrQueryResponse();- NamedList<Object> responseHeader = new SimpleOrderedMap<Object>();++ final SolrQueryResponse rsp = new SolrQueryResponse();+ final NamedList<Object> responseHeader = new SimpleOrderedMap<>();responseHeader.add("params", req.getOriginalParams().toNamedList());rsp.add("responseHeader", responseHeader);//SolrRequestInfo.setRequestInfo(new SolrRequestInfo(req, rsp));@@ -210,8 +214,8 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCothis.requestHandler.handleRequest(req, rsp);// get statistics and add a header with that- Exception exception = rsp.getException();- int status = exception == null ? 0 : exception instanceof SolrException ? ((SolrException) exception).code() : 500;+ final Exception exception = rsp.getException();+ final int status = exception == null ? 0 : exception instanceof SolrException ? ((SolrException) exception).code() : 500;responseHeader.add("status", status);responseHeader.add("QTime",(int) (System.currentTimeMillis() - startTime));@@ -219,43 +223,43 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo// return resultreturn rsp;}-+/*** conversion from a SolrQueryResponse (which is a solr-internal data format) to SolrDocumentList (which is a solrj-format)* The conversion is done inside the solrj api using the BinaryResponseWriter and a very complex unfolding process- * via org.apache.solr.common.util.JavaBinCodec.marshal.+ * via org.apache.solr.common.util.JavaBinCodec.marshal.* @param request* @param sqr* @return*/public SolrDocumentList SolrQueryResponse2SolrDocumentList(final SolrQueryRequest req, final SolrQueryResponse rsp) {- SolrDocumentList sdl = new SolrDocumentList();- NamedList<?> nl = rsp.getValues();- ResultContext resultContext = (ResultContext) nl.get("response");- DocList response = resultContext == null ? new DocSlice(0, 0, new int[0], new float[0], 0, 0.0f, TotalHits.Relation.EQUAL_TO) : resultContext.getDocList();+ final SolrDocumentList sdl = new SolrDocumentList();+ final NamedList<?> nl = rsp.getValues();+ final ResultContext resultContext = (ResultContext) nl.get("response");+ final DocList response = resultContext == null ? new DocSlice(0, 0, new int[0], new float[0], 0, 0.0f, TotalHits.Relation.EQUAL_TO) : resultContext.getDocList();sdl.setNumFound(response == null ? 0 : response.matches());sdl.setStart(response == null ? 0 : response.offset());- String originalName = Thread.currentThread().getName();+ final String originalName = Thread.currentThread().getName();if (response != null) {try {- SolrIndexSearcher searcher = req.getSearcher();+ final SolrIndexSearcher searcher = req.getSearcher();final int responseCount = response.size();- DocIterator iterator = response.iterator();+ final DocIterator iterator = response.iterator();for (int i = 0; i < responseCount; i++) {- int docid = iterator.nextDoc();+ final int docid = iterator.nextDoc();Thread.currentThread().setName("EmbeddedSolrConnector.SolrQueryResponse2SolrDocumentList: " + docid);- Document responsedoc = searcher.doc(docid, (Set<String>) null);- SolrDocument sordoc = doc2SolrDoc(responsedoc);+ final Document responsedoc = searcher.doc(docid, (Set<String>) null);+ final SolrDocument sordoc = this.doc2SolrDoc(responsedoc);sdl.add(sordoc);}- } catch (IOException e) {+ } catch (final IOException e) {ConcurrentLog.logException(e);}}Thread.currentThread().setName(originalName);return sdl;}-+/*** The following schemaFieldCache is a hack-patch of a Solr internal request which is really slow.* The Solr-internal method is flexible because it may respond on a real-time schema change, but that@@ -263,25 +267,25 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo*/private final Map<String, SchemaField> schemaFieldCache = new ConcurrentHashMap<>();private final SchemaField getSchemaField(final String fieldName) {- SchemaField sf = schemaFieldCache.get(fieldName);+ SchemaField sf = this.schemaFieldCache.get(fieldName);if (sf == null) {sf = this.core.getLatestSchema().getFieldOrNull(fieldName);- schemaFieldCache.put(fieldName, sf);+ this.schemaFieldCache.put(fieldName, sf);}return sf;}-+public SolrDocument doc2SolrDoc(Document doc) {- SolrDocument solrDoc = new SolrDocument();- for (IndexableField field : doc) {- String fieldName = field.name();- SchemaField sf = getSchemaField(fieldName); // hack-patch of this.core.getLatestSchema().getFieldOrNull(fieldName); makes it a lot faster!!+ final SolrDocument solrDoc = new SolrDocument();+ for (final IndexableField field : doc) {+ final String fieldName = field.name();+ final SchemaField sf = this.getSchemaField(fieldName); // hack-patch of this.core.getLatestSchema().getFieldOrNull(fieldName); makes it a lot faster!!Object val = null;try {FieldType ft = null;if (sf != null) ft = sf.getType();if (ft == null) {- BytesRef bytesRef = field.binaryValue();+ final BytesRef bytesRef = field.binaryValue();if (bytesRef != null) {if (bytesRef.offset == 0 && bytesRef.length == bytesRef.bytes.length) {val = bytesRef.bytes;@@ -296,12 +300,12 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo} else {val = ft.toObject(field);}- } catch (Throwable e) {+ } catch (final Throwable e) {continue;}if (sf != null && sf.multiValued() && !solrDoc.containsKey(fieldName)) {- ArrayList<Object> l = new ArrayList<Object>();+ final ArrayList<Object> l = new ArrayList<>();l.add(val);solrDoc.addField(fieldName, l);} else {@@ -311,7 +315,7 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCoreturn solrDoc;}-+/*** the usage of getResponseByParams is disencouraged for the embedded Solr connector. Please use request(SolrParams) instead.* Reason: Solr makes a very complex folding/unfolding including data compression for SolrQueryResponses.@@ -320,7 +324,7 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCopublic QueryResponse getResponseByParams(ModifiableSolrParams params) throws IOException {if (this.server == null) throw new IOException("server disconnected");// during the solr query we set the thread name to the query string to get more debugging info in thread dumps- String threadname = Thread.currentThread().getName();+ final String threadname = Thread.currentThread().getName();String ql = "";try {ql = URLDecoder.decode(params.toString(), StandardCharsets.UTF_8.name());} catch (UnsupportedEncodingException|IllegalStateException e) {e.printStackTrace();}Thread.currentThread().setName("Embedded.getResponseByParams solr query: q=" + ql);@@ -328,6 +332,7 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo//System.out.println("EmbeddedSolrConnector.getResponseByParams * QUERY: " + ql); System.out.println("STACKTRACE: " + ConcurrentLog.stackTrace());QueryResponse rsp;try {+ System.out.println("*** PARAMS: " + params);rsp = this.server.query(params);Thread.currentThread().setName(threadname);if (rsp != null) if (log.isFine()) log.fine(rsp.getResults().getNumFound() + " results for " + ql);@@ -350,24 +355,24 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo*/@Overridepublic SolrDocumentList getDocumentListByParams(ModifiableSolrParams params) throws IOException, SolrException {- SolrQueryRequest req = this.request(params);+ final SolrQueryRequest req = this.request(params);SolrQueryResponse response = null;- String q = params.get(CommonParams.Q);- String fq = params.get(CommonParams.FQ);- String sort = params.get(CommonParams.SORT);- String threadname = Thread.currentThread().getName();+ final String q = params.get(CommonParams.Q);+ final String fq = params.get(CommonParams.FQ);+ final String sort = params.get(CommonParams.SORT);+ final String threadname = Thread.currentThread().getName();try {if (q != null) Thread.currentThread().setName("Embedded.getDocumentListByParams solr query: q = " + q + (fq == null ? "" : ", fq = " + fq) + (sort == null ? "" : ", sort = " + sort)); // for debugging in Threaddumpresponse = this.query(req);if (q != null) Thread.currentThread().setName(threadname);if (response == null) throw new IOException("response == null");- return SolrQueryResponse2SolrDocumentList(req, response);+ return this.SolrQueryResponse2SolrDocumentList(req, response);} finally {req.close();}}-+private class DocListSearcher implements AutoCloseable {private SolrQueryRequest request;private DocList response;@@ -375,16 +380,16 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCopublic DocListSearcher(final String querystring, String sort, final int offset, final int count, final String ... fields) {// construct queryfinal SolrQuery params = AbstractSolrConnector.getSolrQuery(querystring, sort, offset, count, fields);-+// query the serverthis.request = EmbeddedSolrConnector.this.request(params);- SolrQueryResponse rsp = query(request);- NamedList<?> nl = rsp.getValues();- ResultContext resultContext = (ResultContext) nl.get("response");+ final SolrQueryResponse rsp = EmbeddedSolrConnector.this.query(this.request);+ final NamedList<?> nl = rsp.getValues();+ final ResultContext resultContext = (ResultContext) nl.get("response");if (resultContext == null) log.warn("DocListSearcher: no response for query '" + querystring + "'");this.response = resultContext == null ? new DocSlice(0, 0, new int[0], new float[0], 0, 0.0f, TotalHits.Relation.EQUAL_TO) : resultContext.getDocList();}-+@Overridepublic void close() {if (this.request != null) this.request.close();@@ -392,7 +397,7 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCothis.response = null;}}-+@Overridepublic long getCountByQuery(String querystring) {long numFound = 0;@@ -400,12 +405,12 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCotry {docListSearcher = new DocListSearcher(querystring, null, 0, 0, CollectionSchema.id.getSolrFieldName());numFound = docListSearcher.response.matches();- } finally {+ } finally {if (docListSearcher != null) docListSearcher.close();}return numFound;}-+/*** check if a given document, identified by url hash as document id exists* @param id the url hash and document id@@ -416,7 +421,7 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCofinal String query = "{!cache=false raw f=" + CollectionSchema.id.getSolrFieldName() + "}" + id;try (DocListSearcher docListSearcher = new DocListSearcher(query, null, 0, 0, CollectionSchema.id.getSolrFieldName())) {return docListSearcher.response.matches() > 0l;- } catch (Throwable e) {+ } catch (final Throwable e) {ConcurrentLog.logException(e);return false;}@@ -436,14 +441,14 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCodocListSearcher = new DocListSearcher("{!cache=false raw f=" + CollectionSchema.id.getSolrFieldName() + "}" + id, null, 0, 1, CollectionSchema.id.getSolrFieldName(), CollectionSchema.load_date_dt.getSolrFieldName());responseCount = docListSearcher.response.size();if (responseCount == 0) return null;- SolrIndexSearcher searcher = docListSearcher.request.getSearcher();- DocIterator iterator = docListSearcher.response.iterator();+ final SolrIndexSearcher searcher = docListSearcher.request.getSearcher();+ final DocIterator iterator = docListSearcher.response.iterator();//for (int i = 0; i < responseCount; i++) {- Document doc = searcher.doc(iterator.nextDoc(), AbstractSolrConnector.SOLR_ID_and_LOAD_DATE_FIELDS);+ final Document doc = searcher.doc(iterator.nextDoc(), AbstractSolrConnector.SOLR_ID_and_LOAD_DATE_FIELDS);if (doc == null) return null;return AbstractSolrConnector.getLoadTimeURL(doc);//}- } catch (Throwable e) {+ } catch (final Throwable e) {ConcurrentLog.logException(e);throw new IOException(e.getMessage());} finally {diff --git a/source/net/yacy/search/Switchboard.java b/source/net/yacy/search/Switchboard.javaindex 75ddf416c..3de654bcf 100644--- a/source/net/yacy/search/Switchboard.java+++ b/source/net/yacy/search/Switchboard.java@@ -215,7 +215,6 @@ import net.yacy.kelondro.workflow.BusyThread;import net.yacy.kelondro.workflow.InstantBusyThread;import net.yacy.kelondro.workflow.OneTimeBusyThread;import net.yacy.kelondro.workflow.WorkflowProcessor;-import net.yacy.kelondro.workflow.WorkflowTask;import net.yacy.kelondro.workflow.WorkflowThread;import net.yacy.peers.DHTSelection;import net.yacy.peers.Dispatcher;@@ -267,8 +266,8 @@ public final class Switchboard extends serverSwitch {private int dhtMaxReferenceCount = 1000;// colored list management- public static SortedSet<String> badwords = new TreeSet<String>(NaturalOrder.naturalComparator);- public static SortedSet<String> stopwords = new TreeSet<String>(NaturalOrder.naturalComparator);+ public static SortedSet<String> badwords = new TreeSet<>(NaturalOrder.naturalComparator);+ public static SortedSet<String> stopwords = new TreeSet<>(NaturalOrder.naturalComparator);public static SortedSet<String> blueList = null;public static SortedSet<byte[]> stopwordHashes = null;public static Blacklist urlBlacklist = null;@@ -333,14 +332,14 @@ public final class Switchboard extends serverSwitch {private boolean terminate = false;private boolean startupAction = true; // this is set to false after the first eventprivate static Switchboard sb;- public HashMap<String, Object[]> crawlJobsStatus = new HashMap<String, Object[]>();+ public HashMap<String, Object[]> crawlJobsStatus = new HashMap<>();public String emptyPasswordAdminAccount;public Switchboard(final File dataPath, final File appPath, final String initPath, final String configPath) {super(dataPath, appPath, initPath, configPath);sb = this;// check if port is already occupied- final int port = getLocalPort();+ final int port = this.getLocalPort();if (TimeoutRequest.ping(Domains.LOCALHOST, port, 500)) {throw new RuntimeException("a server is already running on the YaCy port "@@ -351,15 +350,15 @@ public final class Switchboard extends serverSwitch {MemoryTracker.startSystemProfiling();// set loglevel and log- setLog(new ConcurrentLog("SWITCHBOARD"));+ this.setLog(new ConcurrentLog("SWITCHBOARD"));AccessTracker.setDumpFile(new File(dataPath, "DATA/LOG/queries.log"));// set timeoutrequests- boolean timeoutrequests = getConfigBool("timeoutrequests", true);+ final boolean timeoutrequests = this.getConfigBool("timeoutrequests", true);TimeoutRequest.enable = timeoutrequests;// UPnP port mapping- if ( getConfigBool(SwitchboardConstants.UPNP_ENABLED, false) ) {+ if ( this.getConfigBool(SwitchboardConstants.UPNP_ENABLED, false) ) {new OneTimeBusyThread("UPnP.addPortMappings") {@Override@@ -374,36 +373,36 @@ public final class Switchboard extends serverSwitch {this.tray = new Tray(this);// remote proxy configuration- initRemoteProxy();+ this.initRemoteProxy();// memory configuration- long tableCachingLimit = getConfigLong("tableCachingLimit", 419430400L);+ final long tableCachingLimit = this.getConfigLong("tableCachingLimit", 419430400L);if ( MemoryControl.available() > tableCachingLimit ) {this.useTailCache = true;}- this.exceed134217727 = getConfigBool("exceed134217727", true);+ this.exceed134217727 = this.getConfigBool("exceed134217727", true);if ( MemoryControl.available() > 1024L * 1024L * 1024L * 2L ) {this.exceed134217727 = true;}// load values from configs- final File indexPath = getDataPath(SwitchboardConstants.INDEX_PRIMARY_PATH, SwitchboardConstants.INDEX_PATH_DEFAULT);+ final File indexPath = this.getDataPath(SwitchboardConstants.INDEX_PRIMARY_PATH, SwitchboardConstants.INDEX_PATH_DEFAULT);this.log.config("Index Primary Path: " + indexPath.toString());- final File archivePath = getDataPath(SwitchboardConstants.INDEX_ARCHIVE_PATH, SwitchboardConstants.INDEX_ARCHIVE_DEFAULT);+ final File archivePath = this.getDataPath(SwitchboardConstants.INDEX_ARCHIVE_PATH, SwitchboardConstants.INDEX_ARCHIVE_DEFAULT);this.log.config("Index Archive Path: " + archivePath.toString());this.listsPath =- getDataPath(SwitchboardConstants.LISTS_PATH, SwitchboardConstants.LISTS_PATH_DEFAULT);+ this.getDataPath(SwitchboardConstants.LISTS_PATH, SwitchboardConstants.LISTS_PATH_DEFAULT);this.log.config("Lists Path: " + this.listsPath.toString());this.htDocsPath =- getDataPath(SwitchboardConstants.HTDOCS_PATH, SwitchboardConstants.HTDOCS_PATH_DEFAULT);+ this.getDataPath(SwitchboardConstants.HTDOCS_PATH, SwitchboardConstants.HTDOCS_PATH_DEFAULT);this.log.config("HTDOCS Path: " + this.htDocsPath.toString());- this.workPath = getDataPath(SwitchboardConstants.WORK_PATH, SwitchboardConstants.WORK_PATH_DEFAULT);+ this.workPath = this.getDataPath(SwitchboardConstants.WORK_PATH, SwitchboardConstants.WORK_PATH_DEFAULT);this.workPath.mkdirs();// if default work files exist, copy them (don't overwrite existing!)- File defaultWorkPath = new File(appPath, "defaults/data/work");+ final File defaultWorkPath = new File(appPath, "defaults/data/work");if (defaultWorkPath.list() != null) {- for (String fs : defaultWorkPath.list()) {- File wf = new File(this.workPath, fs);+ for (final String fs : defaultWorkPath.list()) {+ final File wf = new File(this.workPath, fs);if (!wf.exists()) {try {Files.copy(new File(defaultWorkPath, fs), wf);@@ -417,14 +416,14 @@ public final class Switchboard extends serverSwitch {this.log.config("Work Path: " + this.workPath.toString());this.dictionariesPath =- getDataPath(+ this.getDataPath(SwitchboardConstants.DICTIONARY_SOURCE_PATH,SwitchboardConstants.DICTIONARY_SOURCE_PATH_DEFAULT);this.log.config("Dictionaries Path:" + this.dictionariesPath.toString());if (!this.dictionariesPath.exists()) this.dictionariesPath.mkdirs();this.classificationPath =- getDataPath(+ this.getDataPath(SwitchboardConstants.CLASSIFICATION_SOURCE_PATH,SwitchboardConstants.CLASSIFICATION_SOURCE_PATH_DEFAULT);this.log.config("Classification Path:" + this.classificationPath.toString());@@ -468,13 +467,13 @@ public final class Switchboard extends serverSwitch {}.start();// define the "non-password password"- this.emptyPasswordAdminAccount = encodeDigestAuth(getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME,"admin"), "");+ this.emptyPasswordAdminAccount = this.encodeDigestAuth(this.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME,"admin"), "");// init the language detectorthis.log.config("Loading language profiles");try {DetectorFactory.loadProfile(new File(appPath, "langdetect").toString());- } catch (LangDetectException e) {+ } catch (final LangDetectException e) {ConcurrentLog.logException(e);}@@ -482,26 +481,26 @@ public final class Switchboard extends serverSwitch {Domains.init(new File(this.workPath, "globalhosts.list"));// init sessionid name file- final String sessionidNamesFile = getConfig("sessionidNamesFile", "defaults/sessionid.names");+ final String sessionidNamesFile = this.getConfig("sessionidNamesFile", "defaults/sessionid.names");this.log.config("Loading sessionid file " + sessionidNamesFile);- MultiProtocolURL.initSessionIDNames(FileUtils.loadList(new File(getAppPath(), sessionidNamesFile)));+ MultiProtocolURL.initSessionIDNames(FileUtils.loadList(new File(this.getAppPath(), sessionidNamesFile)));// init tablesthis.tables = new WorkTables(this.workPath);// set a high maximum cache size to current size; this is adopted later automatically- final int wordCacheMaxCount = (int) getConfigLong(SwitchboardConstants.WORDCACHE_MAX_COUNT, 20000);- setConfig(SwitchboardConstants.WORDCACHE_MAX_COUNT, Integer.toString(wordCacheMaxCount));+ final int wordCacheMaxCount = (int) this.getConfigLong(SwitchboardConstants.WORDCACHE_MAX_COUNT, 20000);+ this.setConfig(SwitchboardConstants.WORDCACHE_MAX_COUNT, Integer.toString(wordCacheMaxCount));/* Init outgoing connections clients with user defined settings */- initOutgoingConnectionSettings();+ this.initOutgoingConnectionSettings();/* Init outgoing connections pools with user defined settings */- initOutgoingConnectionPools();+ this.initOutgoingConnectionPools();// load the network definitiontry {- overwriteNetworkDefinition(getSysinfo());+ this.overwriteNetworkDefinition(this.getSysinfo());} catch (final FileNotFoundException e) {ConcurrentLog.logException(e);} catch (final IOException e) {@@ -509,14 +508,14 @@ public final class Switchboard extends serverSwitch {}// create custom user agentClientIdentification.generateCustomBot(- getConfig(SwitchboardConstants.CRAWLER_USER_AGENT_NAME, ""),- getConfig(SwitchboardConstants.CRAWLER_USER_AGENT_STRING, ""),- (int) getConfigLong(SwitchboardConstants.CRAWLER_USER_AGENT_MINIMUMDELTA, 500),- (int) getConfigLong(SwitchboardConstants.CRAWLER_USER_AGENT_CLIENTTIMEOUT , 1000));+ this.getConfig(SwitchboardConstants.CRAWLER_USER_AGENT_NAME, ""),+ this.getConfig(SwitchboardConstants.CRAWLER_USER_AGENT_STRING, ""),+ (int) this.getConfigLong(SwitchboardConstants.CRAWLER_USER_AGENT_MINIMUMDELTA, 500),+ (int) this.getConfigLong(SwitchboardConstants.CRAWLER_USER_AGENT_CLIENTTIMEOUT , 1000));// start indexing managementthis.log.config("Starting Indexing Management");- final String networkName = getConfig(SwitchboardConstants.NETWORK_NAME, "");+ final String networkName = this.getConfig(SwitchboardConstants.NETWORK_NAME, "");final long fileSizeMax = (OS.isWindows) ? this.getConfigLong("filesize.max.win", Integer.MAX_VALUE) : this.getConfigLong( "filesize.max.other", Integer.MAX_VALUE);final int redundancy = (int) this.getConfigLong("network.unit.dhtredundancy.senior", 1);final int partitionExponent = (int) this.getConfigLong("network.unit.dht.partitionExponent", 0);@@ -526,15 +525,15 @@ public final class Switchboard extends serverSwitch {this.queuesRoot.mkdirs();// prepare a solr index profile switch list- final File solrCollectionConfigurationInitFile = new File(getAppPath(), "defaults/" + SOLR_COLLECTION_CONFIGURATION_NAME);- final File solrCollectionConfigurationWorkFile = new File(getDataPath(), "DATA/SETTINGS/" + SOLR_COLLECTION_CONFIGURATION_NAME);- final File solrWebgraphConfigurationInitFile = new File(getAppPath(), "defaults/" + SOLR_WEBGRAPH_CONFIGURATION_NAME);- final File solrWebgraphConfigurationWorkFile = new File(getDataPath(), "DATA/SETTINGS/" + SOLR_WEBGRAPH_CONFIGURATION_NAME);+ final File solrCollectionConfigurationInitFile = new File(this.getAppPath(), "defaults/" + SOLR_COLLECTION_CONFIGURATION_NAME);+ final File solrCollectionConfigurationWorkFile = new File(this.getDataPath(), "DATA/SETTINGS/" + SOLR_COLLECTION_CONFIGURATION_NAME);+ final File solrWebgraphConfigurationInitFile = new File(this.getAppPath(), "defaults/" + SOLR_WEBGRAPH_CONFIGURATION_NAME);+ final File solrWebgraphConfigurationWorkFile = new File(this.getDataPath(), "DATA/SETTINGS/" + SOLR_WEBGRAPH_CONFIGURATION_NAME);CollectionConfiguration solrCollectionConfigurationWork = null;WebgraphConfiguration solrWebgraphConfigurationWork = null;// migrate the old Schema file path to a new one- final File solrCollectionConfigurationWorkOldFile = new File(getDataPath(), "DATA/SETTINGS/" + SOLR_COLLECTION_CONFIGURATION_NAME_OLD);+ final File solrCollectionConfigurationWorkOldFile = new File(this.getDataPath(), "DATA/SETTINGS/" + SOLR_COLLECTION_CONFIGURATION_NAME_OLD);if (solrCollectionConfigurationWorkOldFile.exists() && !solrCollectionConfigurationWorkFile.exists()) solrCollectionConfigurationWorkOldFile.renameTo(solrCollectionConfigurationWorkFile);// initialize the collection schema if it does not yet exist@@ -543,7 +542,7 @@ public final class Switchboard extends serverSwitch {} catch (final IOException e) {ConcurrentLog.logException(e);}// lazy definition of schema: do not write empty fields- final boolean solrlazy = getConfigBool(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_LAZY, true);+ final boolean solrlazy = this.getConfigBool(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_LAZY, true);// define collection schematry {@@ -573,10 +572,10 @@ public final class Switchboard extends serverSwitch {Ranking.setQuantRate(this.getConfigFloat(SwitchboardConstants.SEARCH_RANKING_SOLR_DOUBLEDETECTION_QUANTRATE, 0.5f));for (int i = 0; i <= 3; i++) {// must be done every time the boosts change- Ranking r = solrCollectionConfigurationWork.getRanking(i);- String name = this.getConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTNAME_ + i, "_dummy" + i);+ final Ranking r = solrCollectionConfigurationWork.getRanking(i);+ final String name = this.getConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTNAME_ + i, "_dummy" + i);String boosts = this.getConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTFIELDS_ + i, "text_t^1.0");- String fq = this.getConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_FILTERQUERY_ + i, "");+ final String fq = this.getConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_FILTERQUERY_ + i, "");String bq = this.getConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTQUERY_ + i, "");String bf = this.getConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTFUNCTION_ + i, "");// apply some hard-coded patches for earlier experiments we do not want any more@@ -594,9 +593,9 @@ public final class Switchboard extends serverSwitch {}// initialize index- ReferenceContainer.maxReferences = getConfigInt("index.maxReferences", 0);+ ReferenceContainer.maxReferences = this.getConfigInt("index.maxReferences", 0);final File segmentsPath = new File(new File(indexPath, networkName), "SEGMENTS");- try {this.index = new Segment(this.log, segmentsPath, archivePath, solrCollectionConfigurationWork, solrWebgraphConfigurationWork);} catch (IOException e) {ConcurrentLog.logException(e);}+ try {this.index = new Segment(this.log, segmentsPath, archivePath, solrCollectionConfigurationWork, solrWebgraphConfigurationWork);} catch (final IOException e) {ConcurrentLog.logException(e);}if (this.getConfigBool(SwitchboardConstants.CORE_SERVICE_RWI, true)) try {this.index.connectRWI(wordCacheMaxCount, fileSizeMax);} catch (final IOException e) {ConcurrentLog.logException(e);}@@ -610,20 +609,20 @@ public final class Switchboard extends serverSwitch {this.index.fulltext().setUseWebgraph(this.getConfigBool(SwitchboardConstants.CORE_SERVICE_WEBGRAPH, false));// set up the solr interface- final String solrurls = getConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_URL, "http://127.0.0.1:8983/solr");- final boolean usesolr = getConfigBool(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_ENABLED,+ final String solrurls = this.getConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_URL, "http://127.0.0.1:8983/solr");+ final boolean usesolr = this.getConfigBool(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_ENABLED,SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_ENABLED_DEFAULT) & solrurls.length() > 0;- final int solrtimeout = getConfigInt(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_TIMEOUT, 60000);- final boolean writeEnabled = getConfigBool(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_WRITEENABLED, true);+ final int solrtimeout = this.getConfigInt(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_TIMEOUT, 60000);+ final boolean writeEnabled = this.getConfigBool(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_WRITEENABLED, true);final boolean trustSelfSignedOnAuthenticatedServer = Switchboard.getSwitchboard().getConfigBool(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_AUTHENTICATED_ALLOW_SELF_SIGNED,SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_AUTHENTICATED_ALLOW_SELF_SIGNED_DEFAULT);if (usesolr && solrurls != null && solrurls.length() > 0) {try {- ArrayList<RemoteInstance> instances = RemoteInstance.getShardInstances(solrurls, null, null, solrtimeout, trustSelfSignedOnAuthenticatedServer);- String shardMethodName = getConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_SHARDING, ShardSelection.Method.MODULO_HOST_MD5.name());- ShardSelection.Method shardMethod = ShardSelection.Method.valueOf(shardMethodName);+ final ArrayList<RemoteInstance> instances = RemoteInstance.getShardInstances(solrurls, null, null, solrtimeout, trustSelfSignedOnAuthenticatedServer);+ final String shardMethodName = this.getConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_SHARDING, ShardSelection.Method.MODULO_HOST_MD5.name());+ final ShardSelection.Method shardMethod = ShardSelection.Method.valueOf(shardMethodName);this.index.fulltext().connectRemoteSolr(instances, shardMethod, writeEnabled);} catch (final IOException e ) {ConcurrentLog.logException(e);@@ -643,38 +642,43 @@ public final class Switchboard extends serverSwitch {partitionExponent,false,this.exceed134217727);- String agent = getConfig(SwitchboardConstants.NETWORK_UNIT_AGENT, "");+ final String agent = this.getConfig(SwitchboardConstants.NETWORK_UNIT_AGENT, "");if (!agent.isEmpty()) this.peers.setMyName(agent); // this can thus be set using the environment variable yacy.network.unit.agent++ // initialize peer scanthis.localcluster_scan = Collections.newSetFromMap(new ConcurrentHashMap<>());- new OneTimeBusyThread("Switchboard.scanForOtherYaCyInIntranet") {- @Override- public boolean jobImpl() throws Exception {- Switchboard.this.localcluster_scan.addAll(Scanner.scanForOtherYaCyInIntranet());- return true;- }- }.start();+ if (this.getConfigBool("scan.enabled", false)) {+ new OneTimeBusyThread("Switchboard.scanForOtherYaCyInIntranet") {+ @Override+ public boolean jobImpl() throws Exception {+ Switchboard.this.localcluster_scan.addAll(Scanner.scanForOtherYaCyInIntranet());+ return true;+ }+ }.start();+ }+// initialize hazelcast- InterfacesConfig interfacesConfig = new InterfacesConfig();+ final InterfacesConfig interfacesConfig = new InterfacesConfig();Domains.myIntranetIPs().forEach(ip -> interfacesConfig.addInterface(ip.getHostAddress()));- NetworkConfig networkConfig = new NetworkConfig().setInterfaces(interfacesConfig);- JoinConfig join = networkConfig.getJoin();+ final NetworkConfig networkConfig = new NetworkConfig().setInterfaces(interfacesConfig);+ final JoinConfig join = networkConfig.getJoin();join.getMulticastConfig().setEnabled(true);- Config config = new Config().setClusterName("YaCyP2P").setInstanceName("Peer").setNetworkConfig(networkConfig);+ final Config config = new Config().setClusterName("YaCyP2P").setInstanceName("Peer").setNetworkConfig(networkConfig);config.getCPSubsystemConfig().setCPMemberCount(3);this.localcluster_hazelcast = Hazelcast.newHazelcastInstance(config);- String uuid = this.localcluster_hazelcast.getCluster().getLocalMember().getUuid().toString();+ final String uuid = this.localcluster_hazelcast.getCluster().getLocalMember().getUuid().toString();this.localcluster_hazelcast.getMap("status").put(uuid, Memory.status());// load domainListtry {this.domainList = null;- if (!getConfig("network.unit.domainlist", "").equals("")) {- final Reader r = getConfigFileFromWebOrLocally(- getConfig("network.unit.domainlist", ""),- getAppPath().getAbsolutePath(),+ if (!this.getConfig("network.unit.domainlist", "").equals("")) {+ final Reader r = this.getConfigFileFromWebOrLocally(+ this.getConfig("network.unit.domainlist", ""),+ this.getAppPath().getAbsolutePath(),new File(this.networkRoot, "domainlist.txt"));this.domainList = new FilterEngine();- BufferedReader br = new BufferedReader(r);+ final BufferedReader br = new BufferedReader(r);this.domainList.loadList(br, null);br.close();}@@ -694,7 +698,7 @@ public final class Switchboard extends serverSwitch {@Overridepublic boolean jobImpl() throws Exception {- loadSeedLists();+ Switchboard.this.loadSeedLists();return true;}}.start();@@ -723,12 +727,12 @@ public final class Switchboard extends serverSwitch {if ( blueList == null ) {// read only once upon first instantiation of this classfinal String f =- getConfig(SwitchboardConstants.LIST_BLUE, SwitchboardConstants.LIST_BLUE_DEFAULT);+ this.getConfig(SwitchboardConstants.LIST_BLUE, SwitchboardConstants.LIST_BLUE_DEFAULT);final File plasmaBlueListFile = new File(f);if ( f != null ) {blueList = SetTools.loadList(plasmaBlueListFile, NaturalOrder.naturalComparator);} else {- blueList = new TreeSet<String>();+ blueList = new TreeSet<>();}this.log.config("loaded blue-list from file "+ plasmaBlueListFile.getName()@@ -741,7 +745,7 @@ public final class Switchboard extends serverSwitch {// load blacklistthis.log.config("Loading blacklist ...");final File blacklistsPath =- getDataPath(SwitchboardConstants.LISTS_PATH, SwitchboardConstants.LISTS_PATH_DEFAULT);+ this.getDataPath(SwitchboardConstants.LISTS_PATH, SwitchboardConstants.LISTS_PATH_DEFAULT);urlBlacklist = new Blacklist(blacklistsPath);ListManager.switchboard = this;ListManager.listsPath = blacklistsPath;@@ -800,35 +804,35 @@ public final class Switchboard extends serverSwitch {// create the cache directorythis.htCachePath =- getDataPath(SwitchboardConstants.HTCACHE_PATH, SwitchboardConstants.HTCACHE_PATH_DEFAULT);+ this.getDataPath(SwitchboardConstants.HTCACHE_PATH, SwitchboardConstants.HTCACHE_PATH_DEFAULT);this.log.info("HTCACHE Path = " + this.htCachePath.getAbsolutePath());final long maxCacheSize =- 1024L * 1024L * Long.parseLong(getConfig(SwitchboardConstants.PROXY_CACHE_SIZE, "2")); // this is megabyte+ 1024L * 1024L * Long.parseLong(this.getConfig(SwitchboardConstants.PROXY_CACHE_SIZE, "2")); // this is megabyteCache.init(this.htCachePath, this.peers.mySeed().hash, maxCacheSize,- getConfigLong(SwitchboardConstants.HTCACHE_SYNC_LOCK_TIMEOUT,+ this.getConfigLong(SwitchboardConstants.HTCACHE_SYNC_LOCK_TIMEOUT,SwitchboardConstants.HTCACHE_SYNC_LOCK_TIMEOUT_DEFAULT),- getConfigInt(SwitchboardConstants.HTCACHE_COMPRESSION_LEVEL,+ this.getConfigInt(SwitchboardConstants.HTCACHE_COMPRESSION_LEVEL,SwitchboardConstants.HTCACHE_COMPRESSION_LEVEL_DEFAULT));final File transactiondir = new File(this.htCachePath, "snapshots");- Transactions.init(transactiondir, getConfigLong(SwitchboardConstants.SNAPSHOTS_WKHTMLTOPDF_TIMEOUT,+ Transactions.init(transactiondir, this.getConfigLong(SwitchboardConstants.SNAPSHOTS_WKHTMLTOPDF_TIMEOUT,SwitchboardConstants.SNAPSHOTS_WKHTMLTOPDF_TIMEOUT_DEFAULT));// create the surrogates directoriesthis.surrogatesInPath =- getDataPath(+ this.getDataPath(SwitchboardConstants.SURROGATES_IN_PATH,SwitchboardConstants.SURROGATES_IN_PATH_DEFAULT);this.log.info("surrogates.in Path = " + this.surrogatesInPath.getAbsolutePath());this.surrogatesInPath.mkdirs();this.surrogatesOutPath =- getDataPath(+ this.getDataPath(SwitchboardConstants.SURROGATES_OUT_PATH,SwitchboardConstants.SURROGATES_OUT_PATH_DEFAULT);this.log.info("surrogates.out Path = " + this.surrogatesOutPath.getAbsolutePath());this.surrogatesOutPath.mkdirs();// copy opensearch heuristic config (if not exist)- final File osdConfig = new File(getDataPath(), "DATA/SETTINGS/heuristicopensearch.conf");+ final File osdConfig = new File(this.getDataPath(), "DATA/SETTINGS/heuristicopensearch.conf");if (!osdConfig.exists()) {final File osdDefaultConfig = new File(appPath, "defaults/heuristicopensearch.conf");this.log.info("heuristic.opensearch list Path = " + osdDefaultConfig.getAbsolutePath());@@ -839,34 +843,34 @@ public final class Switchboard extends serverSwitch {// create the release download directorythis.releasePath =- getDataPath(SwitchboardConstants.RELEASE_PATH, SwitchboardConstants.RELEASE_PATH_DEFAULT);+ this.getDataPath(SwitchboardConstants.RELEASE_PATH, SwitchboardConstants.RELEASE_PATH_DEFAULT);this.releasePath.mkdirs();this.log.info("RELEASE Path = " + this.releasePath.getAbsolutePath());// starting message boardtry {- initMessages();+ this.initMessages();} catch (final IOException e) {ConcurrentLog.logException(e);}// starting wikitry {- initWiki();+ this.initWiki();} catch (final IOException e) {ConcurrentLog.logException(e);}//starting blogtry {- initBlog();+ this.initBlog();} catch (final IOException e) {ConcurrentLog.logException(e);}// init User DBthis.log.config("Loading User DB");- final File userDbFile = new File(getDataPath(), "DATA/SETTINGS/user.heap");+ final File userDbFile = new File(this.getDataPath(), "DATA/SETTINGS/user.heap");try {this.userDB = new UserDB(userDbFile);this.log.config("Loaded User DB from file "@@ -892,7 +896,7 @@ public final class Switchboard extends serverSwitch {}}}- parserPropertiesPath = new File(getDataPath(), "DATA/SETTINGS/");+ parserPropertiesPath = new File(this.getDataPath(), "DATA/SETTINGS/");settingsList = parserPropertiesPath.list();for ( final String l : settingsList ) {if ( l.startsWith("parser.") && l.endsWith(".properties") ) {@@ -910,7 +914,7 @@ public final class Switchboard extends serverSwitch {@Overridepublic void run() {try {- initBookmarks();+ Switchboard.this.initBookmarks();} catch (final IOException e ) {ConcurrentLog.logException(e);}@@ -920,25 +924,25 @@ public final class Switchboard extends serverSwitch {// define a realtime parsable mimetype listthis.log.config("Parser: Initializing Mime Type deny list");- final boolean enableAudioTags = getConfigBool("parser.enableAudioTags", false);+ final boolean enableAudioTags = this.getConfigBool("parser.enableAudioTags", false);this.log.config("Parser: parser.enableAudioTags= "+enableAudioTags);- final Set<String> denyExt = getConfigSet(SwitchboardConstants.PARSER_EXTENSIONS_DENY);- final Set<String> denyMime = getConfigSet(SwitchboardConstants.PARSER_MIME_DENY);+ final Set<String> denyExt = this.getConfigSet(SwitchboardConstants.PARSER_EXTENSIONS_DENY);+ final Set<String> denyMime = this.getConfigSet(SwitchboardConstants.PARSER_MIME_DENY);/* audioTagParser is disabled by default as it needs a temporary file (because of the JAudiotagger implementation) for each parsed document */if (!enableAudioTags) {denyExt.addAll(audioTagParser.SupportedAudioFormat.getAllFileExtensions());denyMime.addAll(audioTagParser.SupportedAudioFormat.getAllMediaTypes());- setConfig(SwitchboardConstants.PARSER_EXTENSIONS_DENY, denyExt);- setConfig(SwitchboardConstants.PARSER_MIME_DENY, denyMime);- setConfig("parser.enableAudioTags", true);+ this.setConfig(SwitchboardConstants.PARSER_EXTENSIONS_DENY, denyExt);+ this.setConfig(SwitchboardConstants.PARSER_MIME_DENY, denyMime);+ this.setConfig("parser.enableAudioTags", true);}- TextParser.setDenyMime(getConfig(SwitchboardConstants.PARSER_MIME_DENY, ""));- TextParser.setDenyExtension(getConfig(SwitchboardConstants.PARSER_EXTENSIONS_DENY, ""));- pdfParser.individualPages = getConfigBool(SwitchboardConstants.PARSER_PDF_INDIVIDUALPAGES, false);- pdfParser.individualPagePropertyname = getConfig(SwitchboardConstants.PARSER_PDF_INDIVIDUALPAGES_KEY, "page");+ TextParser.setDenyMime(this.getConfig(SwitchboardConstants.PARSER_MIME_DENY, ""));+ TextParser.setDenyExtension(this.getConfig(SwitchboardConstants.PARSER_EXTENSIONS_DENY, ""));+ pdfParser.individualPages = this.getConfigBool(SwitchboardConstants.PARSER_PDF_INDIVIDUALPAGES, false);+ pdfParser.individualPagePropertyname = this.getConfig(SwitchboardConstants.PARSER_PDF_INDIVIDUALPAGES_KEY, "page");// start a loaderthis.log.config("Starting Crawl Loader");@@ -958,38 +962,38 @@ public final class Switchboard extends serverSwitch {final Map<String, File> oaiFriends =OAIListFriendsLoader.loadListFriendsSources(new File(appPath, "defaults/oaiListFriendsSource.xml"),- getDataPath());+ this.getDataPath());OAIListFriendsLoader.init(this.loader, oaiFriends, ClientIdentification.yacyInternetCrawlerAgent);this.crawlQueues = new CrawlQueues(this, this.queuesRoot);// on startup, resume all crawls- setConfig(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL + "_isPaused", "false");- setConfig(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL + "_isPaused_cause", "");- setConfig(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL + "_isPaused", "false");- setConfig(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL + "_isPaused_cause", "");- setConfig(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER + "_isPaused", "false");- setConfig(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER + "_isPaused_cause", "");+ this.setConfig(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL + "_isPaused", "false");+ this.setConfig(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL + "_isPaused_cause", "");+ this.setConfig(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL + "_isPaused", "false");+ this.setConfig(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL + "_isPaused_cause", "");+ this.setConfig(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER + "_isPaused", "false");+ this.setConfig(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER + "_isPaused_cause", "");this.crawlJobsStatus.put(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL, new Object[] {new Object(), false});this.crawlJobsStatus.put(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL, new Object[] {new Object(), false});this.crawlJobsStatus.put(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER, new Object[] {new Object(), false});// init cookie-Monitorthis.log.config("Starting Cookie Monitor");- this.outgoingCookies = new ConcurrentHashMap<String, Object[]>();- this.incomingCookies = new ConcurrentHashMap<String, Object[]>();+ this.outgoingCookies = new ConcurrentHashMap<>();+ this.incomingCookies = new ConcurrentHashMap<>();// init search history trackers- this.localSearchTracker = new ConcurrentHashMap<String, TreeSet<Long>>(); // String:TreeSet - IP:set of Long(accessTime)- this.remoteSearchTracker = new ConcurrentHashMap<String, TreeSet<Long>>();+ this.localSearchTracker = new ConcurrentHashMap<>(); // String:TreeSet - IP:set of Long(accessTime)+ this.remoteSearchTracker = new ConcurrentHashMap<>();// init messages: clean up message symbolfinal File notifierSource =- new File(getAppPath(), getConfig(+ new File(this.getAppPath(), this.getConfig(SwitchboardConstants.HTROOT_PATH,SwitchboardConstants.HTROOT_PATH_DEFAULT) + "/env/grafics/empty.gif");final File notifierDest =new File(- getDataPath(SwitchboardConstants.HTDOCS_PATH, SwitchboardConstants.HTDOCS_PATH_DEFAULT),+ this.getDataPath(SwitchboardConstants.HTDOCS_PATH, SwitchboardConstants.HTDOCS_PATH_DEFAULT),"notifier.gif");try {Files.copy(notifierSource, notifierDest);@@ -998,7 +1002,7 @@ public final class Switchboard extends serverSwitch {// init nameCacheNoCachingListtry {- Domains.setNoCachingPatterns(getConfig(SwitchboardConstants.HTTPC_NAME_CACHE_CACHING_PATTERNS_NO, ""));+ Domains.setNoCachingPatterns(this.getConfig(SwitchboardConstants.HTTPC_NAME_CACHE_CACHING_PATTERNS_NO, ""));} catch (final PatternSyntaxException pse) {ConcurrentLog.severe("Switchboard", "Invalid regular expression in "+ SwitchboardConstants.HTTPC_NAME_CACHE_CACHING_PATTERNS_NO@@ -1009,7 +1013,7 @@ public final class Switchboard extends serverSwitch {// generate snippets cachethis.log.config("Initializing Snippet Cache");- TextSnippet.statistics.setEnabled(getConfigBool(SwitchboardConstants.DEBUG_SNIPPETS_STATISTICS_ENABLED,+ TextSnippet.statistics.setEnabled(this.getConfigBool(SwitchboardConstants.DEBUG_SNIPPETS_STATISTICS_ENABLED,SwitchboardConstants.DEBUG_SNIPPETS_STATISTICS_ENABLED_DEFAULT));// init the wiki@@ -1036,101 +1040,79 @@ public final class Switchboard extends serverSwitch {this.crawler,this.index,this.peers,- isIntranetMode(),- isGlobalMode(),+ this.isIntranetMode(),+ this.isGlobalMode(),this.domainList); // Intranet and Global mode may be both true!// possibly switch off localIP check- Domains.setNoLocalCheck(isAllIPMode());+ Domains.setNoLocalCheck(this.isAllIPMode());// check status of account configuration: when local url crawling is allowed, it is not allowed// that an automatic authorization of localhost is done, because in this case crawls from local// addresses are blocked to prevent attack szenarios where remote pages contain links to localhost// addresses that can steer a YaCy peer- if ( !getConfigBool(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST, false) ) {- if ( getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "").startsWith("0000") ) {+ if ( !this.getConfigBool(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST, false) ) {+ if ( this.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "").startsWith("0000") ) {// the password was set automatically with a random value.// We must remove that here to prevent that a user cannot log in any more- setConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "");+ this.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "");// after this a message must be generated to alert the user to set a new passwordthis.log.info("RANDOM PASSWORD REMOVED! User must set a new password");}}// initializing dht chunk generation- this.dhtMaxReferenceCount = (int) getConfigLong(SwitchboardConstants.INDEX_DIST_CHUNK_SIZE_START, 50);+ this.dhtMaxReferenceCount = (int) this.getConfigLong(SwitchboardConstants.INDEX_DIST_CHUNK_SIZE_START, 50);// init robinson cluster// before we do that, we wait some time until the seed list is loaded.- this.clusterhashes = this.peers.clusterHashes(getConfig("cluster.peers.yacydomain", ""));+ this.clusterhashes = this.peers.clusterHashes(this.getConfig("cluster.peers.yacydomain", ""));// deploy blocking threadsthis.indexingStorageProcessor =- new WorkflowProcessor<IndexingQueueEntry>(+ new WorkflowProcessor<>("storeDocumentIndex","This is the sequencing step of the indexing queue. Files are written as streams, too much councurrency would destroy IO performance. In this process the words are written to the RWI cache, which flushes if it is full.",new String[] {"RWI/Cache/Collections"},- new WorkflowTask<IndexingQueueEntry>() {-- @Override- public IndexingQueueEntry process(final IndexingQueueEntry in) throws Exception {- storeDocumentIndex(in);- return null;- }+ in -> {+ Switchboard.this.storeDocumentIndex(in);+ return null;},2,null,1);this.indexingAnalysisProcessor =- new WorkflowProcessor<IndexingQueueEntry>(+ new WorkflowProcessor<>("webStructureAnalysis","This just stores the link structure of the document into a web structure database.",new String[] {"storeDocumentIndex"},- new WorkflowTask<IndexingQueueEntry>() {-- @Override- public IndexingQueueEntry process(final IndexingQueueEntry in) throws Exception {- return webStructureAnalysis(in);- }- },+ in -> Switchboard.this.webStructureAnalysis(in),WorkflowProcessor.availableCPU + 1,this.indexingStorageProcessor,WorkflowProcessor.availableCPU);this.indexingCondensementProcessor =- new WorkflowProcessor<IndexingQueueEntry>(+ new WorkflowProcessor<>("condenseDocument","This does a structural analysis of plain texts: markup of headlines, slicing into phrases (i.e. sentences), markup with position, counting of words, calculation of term frequency.",new String[] {"webStructureAnalysis"},- new WorkflowTask<IndexingQueueEntry>() {-- @Override- public IndexingQueueEntry process(final IndexingQueueEntry in) throws Exception {- return condenseDocument(in);- }- },+ in -> Switchboard.this.condenseDocument(in),WorkflowProcessor.availableCPU + 1,this.indexingAnalysisProcessor,WorkflowProcessor.availableCPU);this.indexingDocumentProcessor =- new WorkflowProcessor<IndexingQueueEntry>(+ new WorkflowProcessor<>("parseDocument","This does the parsing of the newly loaded documents from the web. The result is not only a plain text document, but also a list of URLs that are embedded into the document. The urls are handed over to the CrawlStacker. This process has two child process queues!",new String[] {"condenseDocument", "CrawlStacker"},- new WorkflowTask<IndexingQueueEntry>() {-- @Override- public IndexingQueueEntry process(final IndexingQueueEntry in) throws Exception {- return parseDocument(in);- }- },+ in -> Switchboard.this.parseDocument(in),Math.max(20, WorkflowProcessor.availableCPU * 2), // it may happen that this is filled with new files from the search process. That means there should be enough place for two result pagesthis.indexingCondensementProcessor,WorkflowProcessor.availableCPU);@@ -1139,7 +1121,7 @@ public final class Switchboard extends serverSwitch {this.log.config("Starting Threads");MemoryControl.gc(10000, "plasmaSwitchboard, help for profiler"); // help for profiler - thq- deployThread(+ this.deployThread(SwitchboardConstants.CLEANUP,"Cleanup","cleaning process",@@ -1148,12 +1130,12 @@ public final class Switchboard extends serverSwitch {@Overridepublic boolean jobImpl() throws Exception {- return cleanupJob();+ return Switchboard.this.cleanupJob();}@Overridepublic int getJobCount() {- return cleanupJobSize();+ return Switchboard.this.cleanupJobSize();}@Override@@ -1163,7 +1145,7 @@ public final class Switchboard extends serverSwitch {},60000); // all 10 minutes, wait 1 minute until first run- deployThread(+ this.deployThread(SwitchboardConstants.SCHEDULER,"Scheduler","starts scheduled processes from the API Processing table",@@ -1171,12 +1153,12 @@ public final class Switchboard extends serverSwitch {new InstantBusyThread("Switchboard.schedulerJob", 30000, 10000) {@Overridepublic boolean jobImpl() throws Exception {- return schedulerJob();+ return Switchboard.this.schedulerJob();}@Overridepublic int getJobCount() {- return schedulerJobSize();+ return Switchboard.this.schedulerJobSize();}@Override@@ -1185,7 +1167,7 @@ public final class Switchboard extends serverSwitch {},60000); // all 10 minutes, wait 1 minute until first run- deployThread(+ this.deployThread(SwitchboardConstants.SURROGATES,"Surrogates","A thread that polls the SURROGATES path and puts all Documents in one surroagte file into the indexing queue.",@@ -1193,17 +1175,17 @@ public final class Switchboard extends serverSwitch {new InstantBusyThread("Switchboard.surrogateProcess", 20000, 0) {@Overridepublic boolean jobImpl() throws Exception {- return surrogateProcess();+ return Switchboard.this.surrogateProcess();}@Overridepublic int getJobCount() {- return surrogateQueueSize();+ return Switchboard.this.surrogateQueueSize();}@Overridepublic void freememImpl() {- surrogateFreeMem();+ Switchboard.this.surrogateFreeMem();}},10000);@@ -1212,7 +1194,7 @@ public final class Switchboard extends serverSwitch {this.initAutocrawl(this.getConfigBool(SwitchboardConstants.AUTOCRAWL, false));final CrawlQueues crawlQueue = this.crawlQueues;- deployThread(+ this.deployThread(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL,"Local Crawl","thread that performes a single crawl step from the local crawl queue",@@ -1236,7 +1218,7 @@ public final class Switchboard extends serverSwitch {10000);final Network net = this.yc;- deployThread(+ this.deployThread(SwitchboardConstants.SEED_UPLOAD,"Seed-List Upload","task that a principal peer performes to generate and upload a seed-list to a ftp account",@@ -1250,7 +1232,7 @@ public final class Switchboard extends serverSwitch {},180000);- deployThread(+ this.deployThread(SwitchboardConstants.PEER_PING,"YaCy Core","this is the p2p-control and peer-ping task",@@ -1263,7 +1245,7 @@ public final class Switchboard extends serverSwitch {}},10000);- deployThread(+ this.deployThread(SwitchboardConstants.INDEX_DIST,"DHT Distribution","selection, transfer and deletion of index entries that are not searched on your peer, but on others",@@ -1271,17 +1253,17 @@ public final class Switchboard extends serverSwitch {new InstantBusyThread("Switchboard.dhtTransferJob", 10000, 1000) {@Overridepublic boolean jobImpl() throws Exception {- return dhtTransferJob();+ return Switchboard.this.dhtTransferJob();}},60000,- Long.parseLong(getConfig(SwitchboardConstants.INDEX_DIST_IDLESLEEP, "5000")),- Long.parseLong(getConfig(SwitchboardConstants.INDEX_DIST_BUSYSLEEP, "0")),- Long.parseLong(getConfig(SwitchboardConstants.INDEX_DIST_MEMPREREQ, "1000000")),- Double.parseDouble(getConfig(SwitchboardConstants.INDEX_DIST_LOADPREREQ, "9.0")));+ Long.parseLong(this.getConfig(SwitchboardConstants.INDEX_DIST_IDLESLEEP, "5000")),+ Long.parseLong(this.getConfig(SwitchboardConstants.INDEX_DIST_BUSYSLEEP, "0")),+ Long.parseLong(this.getConfig(SwitchboardConstants.INDEX_DIST_MEMPREREQ, "1000000")),+ Double.parseDouble(this.getConfig(SwitchboardConstants.INDEX_DIST_LOADPREREQ, "9.0")));// content control: initialize list sync thread- deployThread(+ this.deployThread("720_ccimport","Content Control Import","this is the content control import thread",@@ -1293,7 +1275,7 @@ public final class Switchboard extends serverSwitch {3000, 3000),2000);- deployThread(+ this.deployThread("730_ccfilter","Content Control Filter","this is the content control filter update thread",@@ -1303,7 +1285,7 @@ public final class Switchboard extends serverSwitch {// set network-specific performance attributesif ( this.firstInit ) {- setRemotecrawlPPM(Math.max(1, (int) getConfigLong("network.unit.remotecrawl.speed", 60)));+ this.setRemotecrawlPPM(Math.max(1, (int) this.getConfigLong("network.unit.remotecrawl.speed", 60)));}// test routine for snippet fetch@@ -1314,7 +1296,7 @@ public final class Switchboard extends serverSwitch {//plasmaSnippetCache.result scr = snippetCache.retrieve(new URL("http://www.heise.de/security/news/foren/go.shtml?read=1&msg_id=7301419&forum_id=72721"), query, true);//plasmaSnippetCache.result scr = snippetCache.retrieve(new URL("http://www.heise.de/kiosk/archiv/ct/2003/4/20"), query, true, 260);- this.trail = new LinkedBlockingQueue<String>();+ this.trail = new LinkedBlockingQueue<>();this.log.config("Finished Switchboard Initialization");}@@ -1327,10 +1309,10 @@ public final class Switchboard extends serverSwitch {if(systemEnableSniExt == null) {/* Only apply custom configuration when the JVM system option jsse.enableSNIExtension is not defined */HTTPClient.ENABLE_SNI_EXTENSION- .set(getConfigBool(SwitchboardConstants.HTTP_OUTGOING_GENERAL_TLS_SNI_EXTENSION_ENABLED,+ .set(this.getConfigBool(SwitchboardConstants.HTTP_OUTGOING_GENERAL_TLS_SNI_EXTENSION_ENABLED,HTTPClient.ENABLE_SNI_EXTENSION_DEFAULT));- RemoteInstance.ENABLE_SNI_EXTENSION.set(getConfigBool(SwitchboardConstants.HTTP_OUTGOING_REMOTE_SOLR_TLS_SNI_EXTENSION_ENABLED,+ RemoteInstance.ENABLE_SNI_EXTENSION.set(this.getConfigBool(SwitchboardConstants.HTTP_OUTGOING_REMOTE_SOLR_TLS_SNI_EXTENSION_ENABLED,RemoteInstance.ENABLE_SNI_EXTENSION_DEFAULT));}}@@ -1339,27 +1321,27 @@ public final class Switchboard extends serverSwitch {* Initialize outgoing connections pools with user defined settings*/private void initOutgoingConnectionPools() {- int generalPoolMaxTotal = getConfigInt(SwitchboardConstants.HTTP_OUTGOING_POOL_GENERAL_MAX_TOTAL,+ int generalPoolMaxTotal = this.getConfigInt(SwitchboardConstants.HTTP_OUTGOING_POOL_GENERAL_MAX_TOTAL,SwitchboardConstants.HTTP_OUTGOING_POOL_GENERAL_MAX_TOTAL_DEFAULT);if (generalPoolMaxTotal <= 0) {/* Fix eventually wrong value from the config file */generalPoolMaxTotal = SwitchboardConstants.HTTP_OUTGOING_POOL_GENERAL_MAX_TOTAL_DEFAULT;- setConfig(SwitchboardConstants.HTTP_OUTGOING_POOL_GENERAL_MAX_TOTAL, generalPoolMaxTotal);+ this.setConfig(SwitchboardConstants.HTTP_OUTGOING_POOL_GENERAL_MAX_TOTAL, generalPoolMaxTotal);}HTTPClient.initPoolMaxConnections(HTTPClient.CONNECTION_MANAGER, generalPoolMaxTotal);- int remoteSolrPoolMaxTotal = getConfigInt(SwitchboardConstants.HTTP_OUTGOING_POOL_REMOTE_SOLR_MAX_TOTAL,+ int remoteSolrPoolMaxTotal = this.getConfigInt(SwitchboardConstants.HTTP_OUTGOING_POOL_REMOTE_SOLR_MAX_TOTAL,SwitchboardConstants.HTTP_OUTGOING_POOL_REMOTE_SOLR_MAX_TOTAL_DEFAULT);if (remoteSolrPoolMaxTotal <= 0) {/* Fix eventually wrong value from the config file */remoteSolrPoolMaxTotal = SwitchboardConstants.HTTP_OUTGOING_POOL_REMOTE_SOLR_MAX_TOTAL_DEFAULT;- setConfig(SwitchboardConstants.HTTP_OUTGOING_POOL_REMOTE_SOLR_MAX_TOTAL, remoteSolrPoolMaxTotal);+ this.setConfig(SwitchboardConstants.HTTP_OUTGOING_POOL_REMOTE_SOLR_MAX_TOTAL, remoteSolrPoolMaxTotal);}RemoteInstance.initPoolMaxConnections(RemoteInstance.CONNECTION_MANAGER, remoteSolrPoolMaxTotal);}final String getSysinfo() {- return getConfig(SwitchboardConstants.NETWORK_NAME, "") + (isRobinsonMode() ? "-" : "/") + getConfig(SwitchboardConstants.NETWORK_DOMAIN, "global");+ return this.getConfig(SwitchboardConstants.NETWORK_NAME, "") + (this.isRobinsonMode() ? "-" : "/") + this.getConfig(SwitchboardConstants.NETWORK_DOMAIN, "global");}@Override@@ -1371,7 +1353,7 @@ public final class Switchboard extends serverSwitch {@Overridepublic void run() {try {Thread.sleep(10000);} catch (final InterruptedException e) {} // needs httpd up- schedulerJob(); // trigger startup actions+ Switchboard.this.schedulerJob(); // trigger startup actions}}.start();}@@ -1387,18 +1369,18 @@ public final class Switchboard extends serverSwitch {// load network configuration into settingsString networkUnitDefinition =- getConfig("network.unit.definition", "defaults/yacy.network.freeworld.unit");+ this.getConfig("network.unit.definition", "defaults/yacy.network.freeworld.unit");if (networkUnitDefinition.isEmpty()) networkUnitDefinition = "defaults/yacy.network.freeworld.unit"; // patch for a strange failure case where the path was overwritten by empty string// patch old valuesif ( networkUnitDefinition.equals("yacy.network.unit") ) {networkUnitDefinition = "defaults/yacy.network.freeworld.unit";- setConfig("network.unit.definition", networkUnitDefinition);+ this.setConfig("network.unit.definition", networkUnitDefinition);}// remove old release and bootstrap locations- final Iterator<String> ki = configKeys();- final ArrayList<String> d = new ArrayList<String>();+ final Iterator<String> ki = this.configKeys();+ final ArrayList<String> d = new ArrayList<>();String k;while ( ki.hasNext() ) {k = ki.next();@@ -1407,7 +1389,7 @@ public final class Switchboard extends serverSwitch {}}for ( final String s : d ) {- removeConfig(s); // must be removed afterwards otherwise a ki.remove() would not remove the property on file+ this.removeConfig(s); // must be removed afterwards otherwise a ki.remove() would not remove the property on file}// include additional network definition properties into our settings@@ -1417,11 +1399,11 @@ public final class Switchboard extends serverSwitch {// or independently using a bootstrap URLMap<String, String> initProps;final Reader netDefReader =- getConfigFileFromWebOrLocally(networkUnitDefinition, getAppPath().getAbsolutePath(), new File(+ this.getConfigFileFromWebOrLocally(networkUnitDefinition, this.getAppPath().getAbsolutePath(), new File(this.workPath,"network.definition.backup"));initProps = FileUtils.table(netDefReader);- setConfig(initProps);+ this.setConfig(initProps);// set release locationsint i = 0;@@ -1429,7 +1411,7 @@ public final class Switchboard extends serverSwitch {try {cryptoLib = new CryptoLib();while ( true ) {- final String location = getConfig("network.unit.update.location" + i, "");+ final String location = this.getConfig("network.unit.update.location" + i, "");if ( location.isEmpty() ) {break;}@@ -1444,7 +1426,7 @@ public final class Switchboard extends serverSwitch {// get public key if it's in configtry {final String publicKeyString =- getConfig("network.unit.update.location" + i + ".key", null);+ this.getConfig("network.unit.update.location" + i + ".key", null);if ( publicKeyString != null ) {final byte[] publicKeyBytes =Base64Order.standardCoder.decode(publicKeyString.trim());@@ -1462,8 +1444,8 @@ public final class Switchboard extends serverSwitch {}// set white/blacklists- this.networkWhitelist = Domains.makePatterns(getConfig(SwitchboardConstants.NETWORK_WHITELIST, ""));- this.networkBlacklist = Domains.makePatterns(getConfig(SwitchboardConstants.NETWORK_BLACKLIST, ""));+ this.networkWhitelist = Domains.makePatterns(this.getConfig(SwitchboardConstants.NETWORK_WHITELIST, ""));+ this.networkBlacklist = Domains.makePatterns(this.getConfig(SwitchboardConstants.NETWORK_BLACKLIST, ""));/*// in intranet and portal network set robinson mode@@ -1496,13 +1478,13 @@ public final class Switchboard extends serverSwitch {public void switchNetwork(final String networkDefinition) throws FileNotFoundException, IOException {this.log.info("SWITCH NETWORK: switching to '" + networkDefinition + "'");// pause crawls- final boolean lcp = crawlJobIsPaused(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL);+ final boolean lcp = this.crawlJobIsPaused(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL);if ( !lcp ) {- pauseCrawlJob(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL, "network switch to " + networkDefinition);+ this.pauseCrawlJob(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL, "network switch to " + networkDefinition);}- final boolean rcp = crawlJobIsPaused(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);+ final boolean rcp = this.crawlJobIsPaused(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);if ( !rcp ) {- pauseCrawlJob(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL, "network switch to " + networkDefinition);+ this.pauseCrawlJob(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL, "network switch to " + networkDefinition);}// trigger online cautionthis.proxyLastAccess = System.currentTimeMillis() + 3000; // at least 3 seconds online caution to prevent unnecessary action on database meanwhile@@ -1514,8 +1496,8 @@ public final class Switchboard extends serverSwitch {synchronized ( this ) {// remember the solr scheme- CollectionConfiguration collectionConfiguration = this.index.fulltext().getDefaultConfiguration();- WebgraphConfiguration webgraphConfiguration = this.index.fulltext().getWebgraphConfiguration();+ final CollectionConfiguration collectionConfiguration = this.index.fulltext().getDefaultConfiguration();+ final WebgraphConfiguration webgraphConfiguration = this.index.fulltext().getWebgraphConfiguration();// shut downthis.crawler.close();@@ -1532,17 +1514,17 @@ public final class Switchboard extends serverSwitch {this.log.info("SWITCH NETWORK: START UP OF NEW INDEX DATABASE...");// new properties- setConfig("network.unit.definition", networkDefinition);- overwriteNetworkDefinition(getSysinfo());+ this.setConfig("network.unit.definition", networkDefinition);+ this.overwriteNetworkDefinition(this.getSysinfo());final File indexPrimaryPath =- getDataPath(SwitchboardConstants.INDEX_PRIMARY_PATH, SwitchboardConstants.INDEX_PATH_DEFAULT);+ this.getDataPath(SwitchboardConstants.INDEX_PRIMARY_PATH, SwitchboardConstants.INDEX_PATH_DEFAULT);final int wordCacheMaxCount =- (int) getConfigLong(SwitchboardConstants.WORDCACHE_MAX_COUNT, 20000);+ (int) this.getConfigLong(SwitchboardConstants.WORDCACHE_MAX_COUNT, 20000);final long fileSizeMax =(OS.isWindows) ? this.getConfigLong("filesize.max.win", Integer.MAX_VALUE) : this.getConfigLong("filesize.max.other", Integer.MAX_VALUE);final int redundancy = (int) this.getConfigLong("network.unit.dhtredundancy.senior", 1);final int partitionExponent = (int) this.getConfigLong("network.unit.dht.partitionExponent", 0);- final String networkName = getConfig(SwitchboardConstants.NETWORK_NAME, "");+ final String networkName = this.getConfig(SwitchboardConstants.NETWORK_NAME, "");this.networkRoot = new File(new File(indexPrimaryPath, networkName), "NETWORK");this.queuesRoot = new File(new File(indexPrimaryPath, networkName), "QUEUES");this.networkRoot.mkdirs();@@ -1552,8 +1534,8 @@ public final class Switchboard extends serverSwitch {ResultURLs.clearStacks();// remove heuristics- setConfig(SwitchboardConstants.HEURISTIC_SITE, false);- setConfig(SwitchboardConstants.HEURISTIC_OPENSEARCH, false);+ this.setConfig(SwitchboardConstants.HEURISTIC_SITE, false);+ this.setConfig(SwitchboardConstants.HEURISTIC_OPENSEARCH, false);// relocatethis.peers.relocate(@@ -1563,7 +1545,7 @@ public final class Switchboard extends serverSwitch {this.useTailCache,this.exceed134217727);final File segmentsPath = new File(new File(indexPrimaryPath, networkName), "SEGMENTS");- final File archivePath = getDataPath(SwitchboardConstants.INDEX_ARCHIVE_PATH, SwitchboardConstants.INDEX_ARCHIVE_DEFAULT);+ final File archivePath = this.getDataPath(SwitchboardConstants.INDEX_ARCHIVE_PATH, SwitchboardConstants.INDEX_ARCHIVE_DEFAULT);this.index = new Segment(this.log, segmentsPath, archivePath, collectionConfiguration, webgraphConfiguration);if (this.getConfigBool(SwitchboardConstants.CORE_SERVICE_RWI, true)) this.index.connectRWI(wordCacheMaxCount, fileSizeMax);if (this.getConfigBool(SwitchboardConstants.CORE_SERVICE_CITATION, true)) this.index.connectCitation(wordCacheMaxCount, fileSizeMax);@@ -1574,20 +1556,20 @@ public final class Switchboard extends serverSwitch {this.index.fulltext().setUseWebgraph(this.getConfigBool(SwitchboardConstants.CORE_SERVICE_WEBGRAPH, false));// set up the solr interface- final String solrurls = getConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_URL, "http://127.0.0.1:8983/solr");- final boolean usesolr = getConfigBool(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_ENABLED,+ final String solrurls = this.getConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_URL, "http://127.0.0.1:8983/solr");+ final boolean usesolr = this.getConfigBool(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_ENABLED,SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_ENABLED_DEFAULT) & solrurls.length() > 0;- final int solrtimeout = getConfigInt(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_TIMEOUT, 60000);- final boolean writeEnabled = getConfigBool(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_WRITEENABLED, true);+ final int solrtimeout = this.getConfigInt(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_TIMEOUT, 60000);+ final boolean writeEnabled = this.getConfigBool(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_WRITEENABLED, true);final boolean trustSelfSignedOnAuthenticatedServer = Switchboard.getSwitchboard().getConfigBool(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_AUTHENTICATED_ALLOW_SELF_SIGNED,SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_AUTHENTICATED_ALLOW_SELF_SIGNED_DEFAULT);if (usesolr && solrurls != null && solrurls.length() > 0) {try {- ArrayList<RemoteInstance> instances = RemoteInstance.getShardInstances(solrurls, null, null, solrtimeout, trustSelfSignedOnAuthenticatedServer);- String shardMethodName = getConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_SHARDING, ShardSelection.Method.MODULO_HOST_MD5.name());- ShardSelection.Method shardMethod = ShardSelection.Method.valueOf(shardMethodName);+ final ArrayList<RemoteInstance> instances = RemoteInstance.getShardInstances(solrurls, null, null, solrtimeout, trustSelfSignedOnAuthenticatedServer);+ final String shardMethodName = this.getConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_SHARDING, ShardSelection.Method.MODULO_HOST_MD5.name());+ final ShardSelection.Method shardMethod = ShardSelection.Method.valueOf(shardMethodName);this.index.fulltext().connectRemoteSolr(instances, shardMethod, writeEnabled);} catch (final IOException e ) {ConcurrentLog.logException(e);@@ -1607,13 +1589,13 @@ public final class Switchboard extends serverSwitch {// load domainListtry {this.domainList = null;- if ( !getConfig("network.unit.domainlist", "").equals("") ) {- final Reader r = getConfigFileFromWebOrLocally(- getConfig("network.unit.domainlist", ""),- getAppPath().getAbsolutePath(),+ if ( !this.getConfig("network.unit.domainlist", "").equals("") ) {+ final Reader r = this.getConfigFileFromWebOrLocally(+ this.getConfig("network.unit.domainlist", ""),+ this.getAppPath().getAbsolutePath(),new File(this.networkRoot, "domainlist.txt"));this.domainList = new FilterEngine();- BufferedReader br = new BufferedReader(r);+ final BufferedReader br = new BufferedReader(r);this.domainList.loadList(br, null);br.close();}@@ -1630,44 +1612,44 @@ public final class Switchboard extends serverSwitch {this.crawler,this.index,this.peers,- "local.any".indexOf(getConfig(SwitchboardConstants.NETWORK_DOMAIN, "global")) >= 0,- "global.any".indexOf(getConfig(SwitchboardConstants.NETWORK_DOMAIN, "global")) >= 0,+ "local.any".indexOf(this.getConfig(SwitchboardConstants.NETWORK_DOMAIN, "global")) >= 0,+ "global.any".indexOf(this.getConfig(SwitchboardConstants.NETWORK_DOMAIN, "global")) >= 0,this.domainList);}- Domains.setNoLocalCheck(isAllIPMode()); // possibly switch off localIP check+ Domains.setNoLocalCheck(this.isAllIPMode()); // possibly switch off localIP check// start up crawl jobs- continueCrawlJob(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL);- continueCrawlJob(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);+ this.continueCrawlJob(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL);+ this.continueCrawlJob(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);this.log.info("SWITCH NETWORK: FINISHED START UP, new network is now '" + networkDefinition + "'.");// set the network-specific remote crawl ppm- setRemotecrawlPPM(Math.max(1, (int) getConfigLong("network.unit.remotecrawl.speed", 60)));+ this.setRemotecrawlPPM(Math.max(1, (int) this.getConfigLong("network.unit.remotecrawl.speed", 60)));}public void setRemotecrawlPPM(final int ppm) {final long newBusySleep = Math.max(100, 60000 / ppm);// propagate to crawler- final BusyThread rct = getThread(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);- setConfig(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL_BUSYSLEEP, newBusySleep);- setConfig(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL_IDLESLEEP,+ final BusyThread rct = this.getThread(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);+ this.setConfig(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL_BUSYSLEEP, newBusySleep);+ this.setConfig(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL_IDLESLEEP,Math.min(10000, newBusySleep * 10));if (rct != null) {- rct.setBusySleep(getConfigLong(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL_BUSYSLEEP, 1000));- rct.setIdleSleep(getConfigLong(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL_IDLESLEEP, 10000));+ rct.setBusySleep(this.getConfigLong(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL_BUSYSLEEP, 1000));+ rct.setIdleSleep(this.getConfigLong(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL_IDLESLEEP, 10000));}// propagate to loader- final BusyThread rcl = getThread(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER);- setConfig(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER_BUSYSLEEP, newBusySleep * 4);- setConfig(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER_IDLESLEEP,+ final BusyThread rcl = this.getThread(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER);+ this.setConfig(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER_BUSYSLEEP, newBusySleep * 4);+ this.setConfig(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER_IDLESLEEP,Math.min(10000, newBusySleep * 20));if (rcl != null) {- rcl.setBusySleep(getConfigLong(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER_BUSYSLEEP, 1000));- rcl.setIdleSleep(getConfigLong(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER_IDLESLEEP, 10000));+ rcl.setBusySleep(this.getConfigLong(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER_BUSYSLEEP, 1000));+ rcl.setIdleSleep(this.getConfigLong(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER_IDLESLEEP, 10000));}}@@ -1687,9 +1669,9 @@ public final class Switchboard extends serverSwitch {final CrawlQueues queues = this.crawlQueues;- BusyThread rct = getThread(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);+ BusyThread rct = this.getThread(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);if (rct == null) {- deployThread(+ this.deployThread(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL,"Remote Crawl Job","thread that performes a single crawl/indexing step triggered by a remote peer",@@ -1708,14 +1690,14 @@ public final class Switchboard extends serverSwitch {},10000);- rct = getThread(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);+ rct = this.getThread(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);}- rct.setBusySleep(getConfigLong(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL_BUSYSLEEP, 1000));- rct.setIdleSleep(getConfigLong(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL_IDLESLEEP, 10000));+ rct.setBusySleep(this.getConfigLong(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL_BUSYSLEEP, 1000));+ rct.setIdleSleep(this.getConfigLong(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL_IDLESLEEP, 10000));- BusyThread rcl = getThread(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER);+ BusyThread rcl = this.getThread(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER);if (rcl == null) {- deployThread(+ this.deployThread(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER,"Remote Crawl URL Loader","thread that loads remote crawl lists from other peers",@@ -1728,13 +1710,13 @@ public final class Switchboard extends serverSwitch {},10000);- rcl = getThread(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER);+ rcl = this.getThread(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER);}- rcl.setBusySleep(getConfigLong(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER_BUSYSLEEP, 1000));- rcl.setIdleSleep(getConfigLong(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER_IDLESLEEP, 10000));+ rcl.setBusySleep(this.getConfigLong(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER_BUSYSLEEP, 1000));+ rcl.setIdleSleep(this.getConfigLong(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER_IDLESLEEP, 10000));} else { // activate==false, terminate and remove threads- terminateThread(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER, true);- terminateThread(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL, true);+ this.terminateThread(SwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER, true);+ this.terminateThread(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL, true);}}@@ -1745,11 +1727,11 @@ public final class Switchboard extends serverSwitch {public void initAutocrawl(final boolean activate) {this.setConfig(SwitchboardConstants.AUTOCRAWL, activate);if (activate) {- BusyThread acr = getThread(SwitchboardConstants.CRAWLJOB_AUTOCRAWL);+ BusyThread acr = this.getThread(SwitchboardConstants.CRAWLJOB_AUTOCRAWL);if (acr == null) {final CrawlQueues queues = this.crawlQueues;- deployThread(+ this.deployThread(SwitchboardConstants.CRAWLJOB_AUTOCRAWL,"Autocrawl","Thread that selects and automatically adds crawling jobs to the local queue",@@ -1762,11 +1744,11 @@ public final class Switchboard extends serverSwitch {},10000);- acr = getThread(SwitchboardConstants.CRAWLJOB_AUTOCRAWL);+ acr = this.getThread(SwitchboardConstants.CRAWLJOB_AUTOCRAWL);}- acr.setBusySleep(getConfigLong(SwitchboardConstants.CRAWLJOB_AUTOCRAWL_BUSYSLEEP, 10000));- acr.setIdleSleep(getConfigLong(SwitchboardConstants.CRAWLJOB_AUTOCRAWL_IDLESLEEP, 10000));+ acr.setBusySleep(this.getConfigLong(SwitchboardConstants.CRAWLJOB_AUTOCRAWL_BUSYSLEEP, 10000));+ acr.setIdleSleep(this.getConfigLong(SwitchboardConstants.CRAWLJOB_AUTOCRAWL_IDLESLEEP, 10000));}}@@ -1841,19 +1823,19 @@ public final class Switchboard extends serverSwitch {}public boolean isP2PMode() {- return getConfig(SwitchboardConstants.NETWORK_BOOTSTRAP_SEEDLIST_STUB + "0", null) != null;+ return this.getConfig(SwitchboardConstants.NETWORK_BOOTSTRAP_SEEDLIST_STUB + "0", null) != null;}public boolean isIntranetMode() {- return "local.any".indexOf(getConfig(SwitchboardConstants.NETWORK_DOMAIN, "global")) >= 0;+ return "local.any".indexOf(this.getConfig(SwitchboardConstants.NETWORK_DOMAIN, "global")) >= 0;}public boolean isGlobalMode() {- return "global.any".indexOf(getConfig(SwitchboardConstants.NETWORK_DOMAIN, "global")) >= 0;+ return "global.any".indexOf(this.getConfig(SwitchboardConstants.NETWORK_DOMAIN, "global")) >= 0;}public boolean isAllIPMode() {- return "any".indexOf(getConfig(SwitchboardConstants.NETWORK_DOMAIN, "global")) >= 0;+ return "any".indexOf(this.getConfig(SwitchboardConstants.NETWORK_DOMAIN, "global")) >= 0;}/**@@ -1862,7 +1844,7 @@ public final class Switchboard extends serverSwitch {* @return true when in nocheck mode*/public boolean isIPNoCheckMode() {- return isAllIPMode() && getConfigBool(SwitchboardConstants.NETWORK_DOMAIN_NOCHECK, false);+ return this.isAllIPMode() && this.getConfigBool(SwitchboardConstants.NETWORK_DOMAIN_NOCHECK, false);}public boolean isRobinsonMode() {@@ -1870,15 +1852,15 @@ public final class Switchboard extends serverSwitch {// we need to take care that search requests and remote indexing requests go only// to the peers in the same cluster, if we run a robinson cluster.return (this.peers != null && this.peers.sizeConnected() == 0)- || (!getConfigBool(SwitchboardConstants.INDEX_DIST_ALLOW, false) &&- !getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW, false));+ || (!this.getConfigBool(SwitchboardConstants.INDEX_DIST_ALLOW, false) &&+ !this.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW, false));}public boolean isPublicRobinson() {// robinson peers may be member of robinson clusters, which can be public or private// this does not check the robinson attribute, only the specific subtype of the clusterfinal String clustermode =- getConfig(SwitchboardConstants.CLUSTER_MODE, SwitchboardConstants.CLUSTER_MODE_PUBLIC_PEER);+ this.getConfig(SwitchboardConstants.CLUSTER_MODE, SwitchboardConstants.CLUSTER_MODE_PUBLIC_PEER);return (clustermode.equals(SwitchboardConstants.CLUSTER_MODE_PUBLIC_CLUSTER))|| (clustermode.equals(SwitchboardConstants.CLUSTER_MODE_PUBLIC_PEER));}@@ -1891,11 +1873,11 @@ public final class Switchboard extends serverSwitch {if ( peer == null ) {return false;}- if ( !isRobinsonMode() ) {+ if ( !this.isRobinsonMode() ) {return false;}final String clustermode =- getConfig(SwitchboardConstants.CLUSTER_MODE, SwitchboardConstants.CLUSTER_MODE_PUBLIC_PEER);+ this.getConfig(SwitchboardConstants.CLUSTER_MODE, SwitchboardConstants.CLUSTER_MODE_PUBLIC_PEER);if ( clustermode.equals(SwitchboardConstants.CLUSTER_MODE_PUBLIC_CLUSTER) ) {// check if we got the request from a peer in the public clusterreturn this.clusterhashes.contains(ASCII.getBytes(peer));@@ -1909,11 +1891,11 @@ public final class Switchboard extends serverSwitch {if ( seed == null ) {return false;}- if ( !isRobinsonMode() ) {+ if ( !this.isRobinsonMode() ) {return false;}final String clustermode =- getConfig(SwitchboardConstants.CLUSTER_MODE, SwitchboardConstants.CLUSTER_MODE_PUBLIC_PEER);+ this.getConfig(SwitchboardConstants.CLUSTER_MODE, SwitchboardConstants.CLUSTER_MODE_PUBLIC_PEER);if ( clustermode.equals(SwitchboardConstants.CLUSTER_MODE_PUBLIC_CLUSTER) ) {// check if we got the request from a peer in the public clusterreturn this.clusterhashes.contains(ASCII.getBytes(seed.hash));@@ -1928,7 +1910,7 @@ public final class Switchboard extends serverSwitch {*/public HarvestProcess getHarvestProcess(final String hash) {if (this.index.fulltext().getDefaultConnector().exists(hash)) return HarvestProcess.LOADED;- HarvestProcess hp = this.crawlQueues.exists(ASCII.getBytes(hash));+ final HarvestProcess hp = this.crawlQueues.exists(ASCII.getBytes(hash));if (hp != null) return hp;return null; // todo: can also be in error}@@ -1948,7 +1930,7 @@ public final class Switchboard extends serverSwitch {}public RankingProfile getRanking() {- return (getConfig(SwitchboardConstants.SEARCH_RANKING_RWI_PROFILE, "").isEmpty())+ return (this.getConfig(SwitchboardConstants.SEARCH_RANKING_RWI_PROFILE, "").isEmpty())? new RankingProfile(Classification.ContentDomain.TEXT): new RankingProfile("", crypt.simpleDecode(this.getConfig(SwitchboardConstants.SEARCH_RANKING_RWI_PROFILE, "")));}@@ -1961,17 +1943,17 @@ public final class Switchboard extends serverSwitch {* @return null or a service name*/public String onlineCaution() {- if ( System.currentTimeMillis() - this.proxyLastAccess < Integer.parseInt(getConfig(+ if ( System.currentTimeMillis() - this.proxyLastAccess < Integer.parseInt(this.getConfig(SwitchboardConstants.PROXY_ONLINE_CAUTION_DELAY,"100")) ) {return "proxy";}- if ( System.currentTimeMillis() - this.localSearchLastAccess < Integer.parseInt(getConfig(+ if ( System.currentTimeMillis() - this.localSearchLastAccess < Integer.parseInt(this.getConfig(SwitchboardConstants.LOCALSEACH_ONLINE_CAUTION_DELAY,"1000")) ) {return "localsearch";}- if ( System.currentTimeMillis() - this.remoteSearchLastAccess < Integer.parseInt(getConfig(+ if ( System.currentTimeMillis() - this.remoteSearchLastAccess < Integer.parseInt(this.getConfig(SwitchboardConstants.REMOTESEARCH_ONLINE_CAUTION_DELAY,"500")) ) {return "remotesearch";@@ -2023,7 +2005,7 @@ public final class Switchboard extends serverSwitch {* procedure*/public boolean cleanProfiles() throws InterruptedException {- if (getIndexingProcessorsQueueSize() > 0 ||+ if (this.getIndexingProcessorsQueueSize() > 0 ||this.crawlQueues.activeWorkerEntries().size() > 0 ||this.crawlQueues.coreCrawlJobSize() > 0 ||this.crawlQueues.limitCrawlJobSize() > 0 ||@@ -2043,7 +2025,7 @@ public final class Switchboard extends serverSwitch {System.out.println("SWITCHBOARD Performing shutdown steps...");MemoryTracker.stopSystemProfiling();- terminateAllThreads(true);+ this.terminateAllThreads(true);net.yacy.gui.framework.Switchboard.shutdown();this.log.config("SWITCHBOARD SHUTDOWN STEP 2: sending termination signal to threaded indexing");// closing all still running db importer jobs@@ -2186,9 +2168,9 @@ public final class Switchboard extends serverSwitch {baos.write(buffer, 0, size);}baos.flush();- processSurrogateXML(new ByteArrayInputStream(baos.toByteArray()), entry.getName());+ this.processSurrogateXML(new ByteArrayInputStream(baos.toByteArray()), entry.getName());baos.close();- if (shallTerminate()) break;+ if (this.shallTerminate()) break;}} catch (final IOException e ) {ConcurrentLog.logException(e);@@ -2201,30 +2183,30 @@ public final class Switchboard extends serverSwitch {return moved;} else if (s.endsWith(".warc") || s.endsWith(".warc.gz")) {try {- WarcImporter wri = new WarcImporter(infile);+ final WarcImporter wri = new WarcImporter(infile);wri.start();try {wri.join();- } catch (InterruptedException ex) {+ } catch (final InterruptedException ex) {return moved;}moved = infile.renameTo(outfile);- } catch (IOException ex) {+ } catch (final IOException ex) {this.log.warn("IO Error processing warc file " + infile);}return moved;} else if (s.endsWith(".jsonlist") || s.endsWith(".flatjson")) {- return processSurrogateJson(infile, outfile);+ return this.processSurrogateJson(infile, outfile);}InputStream is = null;try {is = new BufferedInputStream(new FileInputStream(infile));if (s.endsWith(".gz")) is = new GZIPInputStream(is, 65535);- processSurrogateXML(is, infile.getName());+ this.processSurrogateXML(is, infile.getName());} catch (final IOException e ) {ConcurrentLog.logException(e);} finally {- if (!shallTerminate()) {+ if (!this.shallTerminate()) {moved = infile.renameTo(outfile);if ( moved ) {// check if this file is already compressed, if not, compress now@@ -2252,7 +2234,7 @@ public final class Switchboard extends serverSwitch {this.log.info("processed surrogate " + infile);}}- if (is != null) try {is.close();} catch (IOException e) {+ if (is != null) try {is.close();} catch (final IOException e) {this.log.warn("Could not close input stream on file " + infile);}}@@ -2263,7 +2245,7 @@ public final class Switchboard extends serverSwitch {// parse a file that can be generated with yacy_grid_parser// see https://github.com/yacy/yacy_grid_parser/blob/master/README.mdthis.log.info("processing json surrogate " + infile);- long starttime = System.currentTimeMillis();+ final long starttime = System.currentTimeMillis();boolean moved = false;FileInputStream fis = null;@@ -2277,7 +2259,7 @@ public final class Switchboard extends serverSwitch {indexer[t] = new Thread("Switchboard.processSurrogateJson-" + t) {@Overridepublic void run() {- VocabularyScraper scraper = new VocabularyScraper();+ final VocabularyScraper scraper = new VocabularyScraper();SolrInputDocument sid;try {while ((sid = sidQueue.take()) != SurrogateReader.POISON_DOCUMENT ) {@@ -2295,9 +2277,9 @@ public final class Switchboard extends serverSwitch {Switchboard.this.index.fulltext().getDefaultConfiguration().enrich(sid, tokenizer.synonyms(), facets);}Switchboard.this.index.putDocument(sid);- } catch (MalformedURLException e) {}+ } catch (final MalformedURLException e) {}}- } catch (InterruptedException e) {+ } catch (final InterruptedException e) {}}};@@ -2306,27 +2288,27 @@ public final class Switchboard extends serverSwitch {try {fis = new FileInputStream(infile);- InputStream is = new BufferedInputStream(fis);+ final InputStream is = new BufferedInputStream(fis);br = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));String line;while ((line = br.readLine()) != null) {- JSONTokener jt = new JSONTokener(line);- JSONObject json = new JSONObject(jt);+ final JSONTokener jt = new JSONTokener(line);+ final JSONObject json = new JSONObject(jt);if ((json.opt("index") != null && json.length() == 1) || json.length() == 0) continue;- SolrInputDocument surrogate = new SolrInputDocument();- for (String key: json.keySet()) {- Object o = json.opt(key);+ final SolrInputDocument surrogate = new SolrInputDocument();+ for (final String key: json.keySet()) {+ final Object o = json.opt(key);if (o == null) continue;if (o instanceof JSONArray) {// transform this into a list- JSONArray a = (JSONArray) o;+ final JSONArray a = (JSONArray) o;// patch altered yacy grid schema (yacy grid does not split url lists into protocol and urlstub)if (key.equals("inboundlinks_sxt")) {// compute inboundlinks_urlstub_sxt and inboundlinks_protocol_sxt- List<Object> urlstub = new ArrayList<>();- List<Object> protocol = new ArrayList<>();+ final List<Object> urlstub = new ArrayList<>();+ final List<Object> protocol = new ArrayList<>();for (int i = 0; i < a.length(); i++) {- AnchorURL b = new AnchorURL((String) a.get(i));+ final AnchorURL b = new AnchorURL((String) a.get(i));urlstub.add(b.urlstub(true, true));protocol.add(b.getProtocol());}@@ -2334,10 +2316,10 @@ public final class Switchboard extends serverSwitch {CollectionSchema.inboundlinks_protocol_sxt.add(surrogate, protocol);} else if (key.equals("outboundlinks_sxt")) {// compute outboundlinks_urlstub_sxt and outboundlinks_protocol_sxt- List<Object> urlstub = new ArrayList<>();- List<Object> protocol = new ArrayList<>();+ final List<Object> urlstub = new ArrayList<>();+ final List<Object> protocol = new ArrayList<>();for (int i = 0; i < a.length(); i++) {- AnchorURL b = new AnchorURL((String) a.get(i));+ final AnchorURL b = new AnchorURL((String) a.get(i));urlstub.add(b.urlstub(true, true));protocol.add(b.getProtocol());}@@ -2345,40 +2327,40 @@ public final class Switchboard extends serverSwitch {CollectionSchema.outboundlinks_protocol_sxt.add(surrogate, protocol);} else if (key.equals("images_sxt")) {// compute images_urlstub_sxt and images_protocol_sxt- List<Object> urlstub = new ArrayList<>();- List<Object> protocol = new ArrayList<>();+ final List<Object> urlstub = new ArrayList<>();+ final List<Object> protocol = new ArrayList<>();for (int i = 0; i < a.length(); i++) {- AnchorURL b = new AnchorURL((String) a.get(i));+ final AnchorURL b = new AnchorURL((String) a.get(i));urlstub.add(b.urlstub(true, true));protocol.add(b.getProtocol());}CollectionSchema.images_urlstub_sxt.add(surrogate, urlstub);CollectionSchema.images_protocol_sxt.add(surrogate, protocol);} else {- List<Object> list = new ArrayList<>();+ final List<Object> list = new ArrayList<>();for (int i = 0; i < a.length(); i++) list.add(a.get(i));- CollectionSchema schema = CollectionSchema.valueOf(key);+ final CollectionSchema schema = CollectionSchema.valueOf(key);schema.add(surrogate, list);}} else {CollectionSchema ctype = null;- try {ctype = CollectionSchema.valueOf(key);} catch (IllegalArgumentException e) {}+ try {ctype = CollectionSchema.valueOf(key);} catch (final IllegalArgumentException e) {}if (key.equals("url_s") || key.equals("sku")) {ctype = CollectionSchema.sku;// patch yacy grid altered schema (yacy grid does not have IDs any more, but they can be re-computed here)- DigestURL durl = new DigestURL(o.toString());- String id = ASCII.String(durl.hash());+ final DigestURL durl = new DigestURL(o.toString());+ final String id = ASCII.String(durl.hash());surrogate.setField(CollectionSchema.sku.getSolrFieldName(), durl.toNormalform(true));surrogate.setField(CollectionSchema.id.getSolrFieldName(), id);surrogate.setField(CollectionSchema.host_id_s.getSolrFieldName(), id.substring(6));} else if (key.equals("referrer_url_s")) {- DigestURL durl = new DigestURL(o.toString());- String id = ASCII.String(durl.hash());+ final DigestURL durl = new DigestURL(o.toString());+ final String id = ASCII.String(durl.hash());surrogate.setField(CollectionSchema.referrer_id_s.getSolrFieldName(), id);} else if (ctype != null && ctype.getType() == SolrType.date) {// patch date into something that Solr can understand- String d = o.toString(); // i.e. Wed Apr 01 02:00:00 CEST 2020- Date dd = d == null || d.length() == 0 ? null : AbstractFormatter.parseAny(d);+ final String d = o.toString(); // i.e. Wed Apr 01 02:00:00 CEST 2020+ final Date dd = d == null || d.length() == 0 ? null : AbstractFormatter.parseAny(d);if (dd != null) surrogate.setField(ctype.getSolrFieldName(), ISO8601Formatter.FORMATTER.format(dd)); // solr dateTime is ISO8601 format} else {surrogate.setField(key, o.toString());@@ -2388,7 +2370,7 @@ public final class Switchboard extends serverSwitch {try {sidQueue.put(surrogate);- } catch (InterruptedException e) {+ } catch (final InterruptedException e) {e.printStackTrace();}}@@ -2398,11 +2380,11 @@ public final class Switchboard extends serverSwitch {// finish indexing threads by giving them poisonfor (int t = 0; t < indexer.length; t++) {- try {sidQueue.put(SurrogateReader.POISON_DOCUMENT);} catch (InterruptedException e) {}+ try {sidQueue.put(SurrogateReader.POISON_DOCUMENT);} catch (final InterruptedException e) {}}// wait until indexer threads are finishedfor (int t = 0; t < indexer.length; t++) {- try {indexer[t].join(10000);} catch (InterruptedException e) {}+ try {indexer[t].join(10000);} catch (final InterruptedException e) {}}moved = infile.renameTo(outfile);@@ -2414,14 +2396,14 @@ public final class Switchboard extends serverSwitch {/* buffered reader was successfully created : close it and its underlying streams */try {br.close();- } catch (IOException e) {+ } catch (final IOException e) {this.log.warn("Could not close reader on file " + infile);}} else if(fis != null) {/* no buffered reader : maybe a case of exhausted memory. Anyway file input stream has to be closed. */try {fis.close();- } catch (IOException e) {+ } catch (final IOException e) {this.log.warn("Could not close input stream on file " + infile);}}@@ -2443,18 +2425,18 @@ public final class Switchboard extends serverSwitch {// start indexer threadsassert this.crawlStacker != null;- Thread[] indexer = new Thread[concurrency];+ final Thread[] indexer = new Thread[concurrency];for (int t = 0; t < concurrency; t++) {indexer[t] = new Thread("Switchboard.processSurrogateXML-" + t) {@Overridepublic void run() {- VocabularyScraper scraper = new VocabularyScraper();+ final VocabularyScraper scraper = new VocabularyScraper();Object surrogateObj;while ((surrogateObj = reader.take()) != SurrogateReader.POISON_DOCUMENT ) {assert surrogateObj != null;/* When parsing a full-text Solr xml data dump Surrogate reader produces SolrInputDocument instances */if(surrogateObj instanceof SolrInputDocument) {- SolrInputDocument surrogate = (SolrInputDocument)surrogateObj;+ final SolrInputDocument surrogate = (SolrInputDocument)surrogateObj;try {// enrich the surrogatefinal String id = (String) surrogate.getFieldValue(CollectionSchema.id.getSolrFieldName());@@ -2476,7 +2458,7 @@ public final class Switchboard extends serverSwitch {myPeerHash,myPeerHash,EventOrigin.SURROGATES);- } catch (MalformedURLException e) {+ } catch (final MalformedURLException e) {ConcurrentLog.logException(e);}// write the surrogate into the index@@ -2502,7 +2484,7 @@ public final class Switchboard extends serverSwitch {Switchboard.this.indexingCondensementProcessor.enQueue(queueEntry);}- if (shallTerminate()) break;+ if (Switchboard.this.shallTerminate()) break;}}};@@ -2512,7 +2494,7 @@ public final class Switchboard extends serverSwitch {// wait for termination of indexer threadsfor (int t = 0; t < concurrency; t++) {- try {indexer[t].join();} catch (InterruptedException e) {}+ try {indexer[t].join();} catch (final InterruptedException e) {}}}@@ -2546,7 +2528,7 @@ public final class Switchboard extends serverSwitch {public boolean surrogateProcess() {// work off fresh entries from the proxy or from the crawler- final String cautionCause = onlineCaution();+ final String cautionCause = this.onlineCaution();if ( cautionCause != null ) {if ( this.log.isFine() ) {this.log.fine("deQueue: online caution for "@@ -2564,7 +2546,7 @@ public final class Switchboard extends serverSwitch {for ( final String surrogate : surrogatelist ) {// check for interruption- checkInterruption();+ this.checkInterruption();if ( surrogate.endsWith(".xml")|| surrogate.endsWith(".xml.gz")@@ -2574,7 +2556,7 @@ public final class Switchboard extends serverSwitch {|| surrogate.endsWith(".jsonlist")|| surrogate.endsWith(".flatjson") ) {// read the surrogate file and store entry in index- if ( processSurrogate(surrogate) ) {+ if ( this.processSurrogate(surrogate) ) {return true;}}@@ -2611,7 +2593,7 @@ public final class Switchboard extends serverSwitch {public int schedulerJobSize() {try {return this.tables.size(WorkTables.TABLE_API_NAME);- } catch (IOException e) {+ } catch (final IOException e) {ConcurrentLog.logException(e);return 0;}@@ -2625,7 +2607,7 @@ public final class Switchboard extends serverSwitch {// execute scheduled API actionsTables.Row row;- final Collection<String> pks = new LinkedHashSet<String>();+ final Collection<String> pks = new LinkedHashSet<>();final Date now = new Date();try {final Iterator<Tables.Row> plainIterator = this.tables.iterator(WorkTables.TABLE_API_NAME);@@ -2648,7 +2630,7 @@ public final class Switchboard extends serverSwitch {// select api calls according to event settingsfinal String kind = row.get(WorkTables.TABLE_API_COL_APICALL_EVENT_KIND, "off");if (!"off".equals(kind)) {- String action = row.get(WorkTables.TABLE_API_COL_APICALL_EVENT_ACTION, "startup");+ final String action = row.get(WorkTables.TABLE_API_COL_APICALL_EVENT_ACTION, "startup");if ("startup".equals(action)) {if (this.startupAction) {pks.add(UTF8.String(row.getPK()));@@ -2658,9 +2640,9 @@ public final class Switchboard extends serverSwitch {}}} else try {- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmm");- long d = dateFormat.parse(dateFormat.format(new Date()).substring(0, 8) + action).getTime();- long cycle = getThread(SwitchboardConstants.CLEANUP).getBusySleep();+ final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmm");+ final long d = dateFormat.parse(dateFormat.format(new Date()).substring(0, 8) + action).getTime();+ final long cycle = this.getThread(SwitchboardConstants.CLEANUP).getBusySleep();if (d < System.currentTimeMillis() && System.currentTimeMillis() - d < cycle) {pks.add(UTF8.String(row.getPK()));if ("once".equals(kind)) {@@ -2678,7 +2660,7 @@ public final class Switchboard extends serverSwitch {this.startupAction = false;// execute api calls- final Map<String, Integer> callResult = this.tables.execAPICalls("localhost", getLocalPort(), pks, getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin"), getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""));+ final Map<String, Integer> callResult = this.tables.execAPICalls("localhost", this.getLocalPort(), pks, this.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin"), this.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""));for ( final Map.Entry<String, Integer> call : callResult.entrySet() ) {this.log.info("Scheduler executed api call, response " + call.getValue() + ": " + call.getKey());}@@ -2709,12 +2691,12 @@ public final class Switchboard extends serverSwitch {// write a thread dump to log pathtry {- File tdlog = new File(this.dataPath, "DATA/LOG/threaddump.txt");- PrintWriter out = new PrintWriter(tdlog);- String threaddump = ThreadDump.threaddump(this, true, 0, false, 0);+ final File tdlog = new File(this.dataPath, "DATA/LOG/threaddump.txt");+ final PrintWriter out = new PrintWriter(tdlog);+ final String threaddump = ThreadDump.threaddump(this, true, 0, false, 0);out.println(threaddump);out.close();- } catch (IOException e) {+ } catch (final IOException e) {this.log.info("cannot write threaddump", e);}@@ -2727,10 +2709,10 @@ public final class Switchboard extends serverSwitch {}// stop greedylearning if limit is reached- if (getConfigBool(SwitchboardConstants.GREEDYLEARNING_ACTIVE, false)) {- long cs = this.index.fulltext().collectionSize();- if (cs > getConfigInt(SwitchboardConstants.GREEDYLEARNING_LIMIT_DOCCOUNT, 0)) {- setConfig(SwitchboardConstants.GREEDYLEARNING_ACTIVE, false);+ if (this.getConfigBool(SwitchboardConstants.GREEDYLEARNING_ACTIVE, false)) {+ final long cs = this.index.fulltext().collectionSize();+ if (cs > this.getConfigInt(SwitchboardConstants.GREEDYLEARNING_LIMIT_DOCCOUNT, 0)) {+ this.setConfig(SwitchboardConstants.GREEDYLEARNING_ACTIVE, false);this.log.info("finishing greedy learning phase, size=" +cs);}}@@ -2789,7 +2771,7 @@ public final class Switchboard extends serverSwitch {ConnectionInfo.cleanUp();// clean up delegated stack- checkInterruption();+ this.checkInterruption();if (this.crawlQueues.delegatedURL != null && (this.crawlQueues.delegatedURL.size() > 1000) ) {if ( this.log.isFine() ) {this.log.fine("Cleaning Delegated-URLs report stack, "@@ -2800,7 +2782,7 @@ public final class Switchboard extends serverSwitch {}// clean up error stack- checkInterruption();+ this.checkInterruption();if ( (this.crawlQueues.errorURL.stackSize() > 1000) ) {if ( this.log.isFine() ) {this.log.fine("Cleaning Error-URLs report stack, "@@ -2812,7 +2794,7 @@ public final class Switchboard extends serverSwitch {// clean up loadedURL stackfor ( final EventOrigin origin : EventOrigin.values() ) {- checkInterruption();+ this.checkInterruption();if ( ResultURLs.getStackSize(origin) > 1000 ) {if ( this.log.isFine() ) {this.log.fine("Cleaning Loaded-URLs report stack, "@@ -2825,7 +2807,7 @@ public final class Switchboard extends serverSwitch {}// clean up news- checkInterruption();+ this.checkInterruption();try {if ( this.log.isFine() ) {this.log.fine("Cleaning Incoming News, "@@ -2836,21 +2818,21 @@ public final class Switchboard extends serverSwitch {} catch (final Exception e ) {ConcurrentLog.logException(e);}- if ( getConfigBool("cleanup.deletionProcessedNews", true) ) {+ if ( this.getConfigBool("cleanup.deletionProcessedNews", true) ) {this.peers.newsPool.clear(NewsPool.PROCESSED_DB);}- if ( getConfigBool("cleanup.deletionPublishedNews", true) ) {+ if ( this.getConfigBool("cleanup.deletionPublishedNews", true) ) {this.peers.newsPool.clear(NewsPool.PUBLISHED_DB);}// clean up seed-dbs- if ( getConfigBool("routing.deleteOldSeeds.permission", true) ) {+ if ( this.getConfigBool("routing.deleteOldSeeds.permission", true) ) {final long deleteOldSeedsTime =- getConfigLong("routing.deleteOldSeeds.time", 7) * 24 * 3600000;+ this.getConfigLong("routing.deleteOldSeeds.time", 7) * 24 * 3600000;Iterator<Seed> e = this.peers.seedsSortedDisconnected(true, Seed.LASTSEEN);Seed seed = null;- final List<String> deleteQueue = new ArrayList<String>();- checkInterruption();+ final List<String> deleteQueue = new ArrayList<>();+ this.checkInterruption();// clean passive seedswhile ( e.hasNext() ) {seed = e.next();@@ -2867,7 +2849,7 @@ public final class Switchboard extends serverSwitch {}deleteQueue.clear();e = this.peers.seedsSortedPotential(true, Seed.LASTSEEN);- checkInterruption();+ this.checkInterruption();// clean potential seedswhile ( e.hasNext() ) {seed = e.next();@@ -2900,7 +2882,7 @@ public final class Switchboard extends serverSwitch {.info("AUTO-UPDATE: omitting update because download failed (file cannot be found, is too small or signature is bad)");} else {if(yacyRelease.deployRelease(downloaded)) {- terminate(10, "auto-update to install " + downloaded.getName());+ this.terminate(10, "auto-update to install " + downloaded.getName());this.log.info("AUTO-UPDATE: deploy and restart initiated");} else {this.log@@ -2910,7 +2892,7 @@ public final class Switchboard extends serverSwitch {}// initiate broadcast about peer startup to spread supporter url- if ( !isRobinsonMode() && this.peers.newsPool.size(NewsPool.OUTGOING_DB) == 0 ) {+ if ( !this.isRobinsonMode() && this.peers.newsPool.size(NewsPool.OUTGOING_DB) == 0 ) {// read profilefinal Properties profile = new Properties();final File profileFile = new File(this.dataPath, "DATA/SETTINGS/profile.txt");@@ -2940,10 +2922,10 @@ public final class Switchboard extends serverSwitch {}// update the cluster set- this.clusterhashes = this.peers.clusterHashes(getConfig("cluster.peers.yacydomain", ""));+ this.clusterhashes = this.peers.clusterHashes(this.getConfig("cluster.peers.yacydomain", ""));// check if we are reachable and try to map port again if not (e.g. when router rebooted)- if ( getConfigBool(SwitchboardConstants.UPNP_ENABLED, false) && this.peers.mySeed().isJunior() ) {+ if ( this.getConfigBool(SwitchboardConstants.UPNP_ENABLED, false) && this.peers.mySeed().isJunior() ) {UPnP.addPortMappings();}@@ -2951,25 +2933,25 @@ public final class Switchboard extends serverSwitch {this.observer.resourceObserverJob();// clean up profiles- checkInterruption();+ this.checkInterruption();// execute the (post-) processing steps for all entries that have a process tag assigned- boolean allCrawlsFinished = this.crawler.allCrawlsFinished(this.crawlQueues);+ final boolean allCrawlsFinished = this.crawler.allCrawlsFinished(this.crawlQueues);int proccount = 0;if (!this.crawlJobIsPaused(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL)) {- Fulltext fulltext = this.index.fulltext();- CollectionConfiguration collection1Configuration = fulltext.getDefaultConfiguration();+ final Fulltext fulltext = this.index.fulltext();+ final CollectionConfiguration collection1Configuration = fulltext.getDefaultConfiguration();- boolean process_key_exist = collection1Configuration.contains(CollectionSchema.process_sxt);+ final boolean process_key_exist = collection1Configuration.contains(CollectionSchema.process_sxt);if (!process_key_exist) this.log.info("postprocessing deactivated: field process_sxt is not enabled");- boolean reference_index_exist = (this.index.connectedCitation() || fulltext.useWebgraph());+ final boolean reference_index_exist = (this.index.connectedCitation() || fulltext.useWebgraph());if (!reference_index_exist) this.log.info("postprocessing deactivated: no reference index avilable; activate citation index or webgraph");- boolean minimum_ram_fullfilled = MemoryControl.available() > getConfigLong("postprocessing.minimum_ram", 0);- if (!minimum_ram_fullfilled) this.log.info("postprocessing deactivated: no enough ram (" + MemoryControl.available() + "), needed " + getConfigLong("postprocessing.minimum_ram", 0) + ", to force change field postprocessing.minimum_ram");- boolean minimum_load_fullfilled = Memory.getSystemLoadAverage() < getConfigFloat("postprocessing.maximum_load", 0);- if (!minimum_load_fullfilled) this.log.info("postprocessing deactivated: too high load (" + Memory.getSystemLoadAverage() + ") > " + getConfigFloat("postprocessing.maximum_load", 0) + ", to force change field postprocessing.maximum_load");- boolean postprocessing = process_key_exist && reference_index_exist && minimum_ram_fullfilled && minimum_load_fullfilled;+ final boolean minimum_ram_fullfilled = MemoryControl.available() > this.getConfigLong("postprocessing.minimum_ram", 0);+ if (!minimum_ram_fullfilled) this.log.info("postprocessing deactivated: no enough ram (" + MemoryControl.available() + "), needed " + this.getConfigLong("postprocessing.minimum_ram", 0) + ", to force change field postprocessing.minimum_ram");+ final boolean minimum_load_fullfilled = Memory.getSystemLoadAverage() < this.getConfigFloat("postprocessing.maximum_load", 0);+ if (!minimum_load_fullfilled) this.log.info("postprocessing deactivated: too high load (" + Memory.getSystemLoadAverage() + ") > " + this.getConfigFloat("postprocessing.maximum_load", 0) + ", to force change field postprocessing.maximum_load");+ final boolean postprocessing = process_key_exist && reference_index_exist && minimum_ram_fullfilled && minimum_load_fullfilled;if (!postprocessing) this.log.info("postprocessing deactivated: constraints violated");if (allCrawlsFinished) {@@ -2979,21 +2961,21 @@ public final class Switchboard extends serverSwitch {if (postprocessing) {// run postprocessing on all profiles- ReferenceReportCache rrCache = this.index.getReferenceReportCache();- proccount += collection1Configuration.postprocessing(this.index, rrCache, null, getConfigBool("postprocessing.partialUpdate", true));+ final ReferenceReportCache rrCache = this.index.getReferenceReportCache();+ proccount += collection1Configuration.postprocessing(this.index, rrCache, null, this.getConfigBool("postprocessing.partialUpdate", true));this.index.fulltext().commit(true); // without a commit the success is not visible in the monitoring}this.crawler.cleanProfiles(this.crawler.getActiveProfiles());this.log.info("cleanup post-processed " + proccount + " documents");} else {- Set<String> deletionCandidates = collection1Configuration.contains(CollectionSchema.harvestkey_s.getSolrFieldName()) ?- this.crawler.getFinishedProfiles(this.crawlQueues) : new HashSet<String>();- int cleanupByHarvestkey = deletionCandidates.size();+ final Set<String> deletionCandidates = collection1Configuration.contains(CollectionSchema.harvestkey_s.getSolrFieldName()) ?+ this.crawler.getFinishedProfiles(this.crawlQueues) : new HashSet<>();+ final int cleanupByHarvestkey = deletionCandidates.size();if (cleanupByHarvestkey > 0) {if (postprocessing) {// run postprocessing on these profiles- ReferenceReportCache rrCache = this.index.getReferenceReportCache();- for (String profileHash: deletionCandidates) proccount += collection1Configuration.postprocessing(this.index, rrCache, profileHash, getConfigBool("postprocessing.partialUpdate", true));+ final ReferenceReportCache rrCache = this.index.getReferenceReportCache();+ for (final String profileHash: deletionCandidates) proccount += collection1Configuration.postprocessing(this.index, rrCache, profileHash, this.getConfigBool("postprocessing.partialUpdate", true));this.index.fulltext().commit(true); // without a commit the success is not visible in the monitoring}this.crawler.cleanProfiles(deletionCandidates);@@ -3030,8 +3012,8 @@ public final class Switchboard extends serverSwitch {// write statisticsif (System.currentTimeMillis() - this.lastStats > 1500000 /*25min, should cause 2 entries every hour at least*/) try {- BEncodedHeap statTable = this.tables.getHeap("stats");- Map<String, byte[]> entry = new LinkedHashMap<>();+ final BEncodedHeap statTable = this.tables.getHeap("stats");+ final Map<String, byte[]> entry = new LinkedHashMap<>();if (this.isP2PMode()) {entry.put("aM", ASCII.getBytes(Integer.toString(this.peers.sizeActiveSince(30 * 1440)))); // activeLastMonthentry.put("aW", ASCII.getBytes(Integer.toString(this.peers.sizeActiveSince(7 * 1440)))); // activeLastWeek@@ -3043,10 +3025,10 @@ public final class Switchboard extends serverSwitch {entry.put("cR", ASCII.getBytes(Long.toString(this.index.RWICount()))); // count of the RWI entries}entry.put("cI", ASCII.getBytes(Long.toString(this.index.fulltext().collectionSize()))); // size of the index (number of documents)- byte[] pk = ASCII.getBytes(GenericFormatter.SHORT_MINUTE_FORMATTER.format()); // the primary key is the date, the maximum length is 12 characters which is sufficient for up-to-minute accuracy+ final byte[] pk = ASCII.getBytes(GenericFormatter.SHORT_MINUTE_FORMATTER.format()); // the primary key is the date, the maximum length is 12 characters which is sufficient for up-to-minute accuracystatTable.put(pk, entry);this.lastStats = System.currentTimeMillis();- } catch (IOException e) {}+ } catch (final IOException e) {}// show deadlocks if there are any in the logif (Memory.deadlocks() > 0) Memory.logDeadlocks();@@ -3071,8 +3053,8 @@ public final class Switchboard extends serverSwitch {synchronized ( status[SwitchboardConstants.CRAWLJOB_SYNC] ) {status[SwitchboardConstants.CRAWLJOB_STATUS] = Boolean.TRUE;}- setConfig(jobType + "_isPaused", "true");- setConfig(jobType + "_isPaused_cause", cause);+ this.setConfig(jobType + "_isPaused", "true");+ this.setConfig(jobType + "_isPaused_cause", cause);this.log.warn("Crawl job '" + jobType + "' is paused: " + cause);}@@ -3089,7 +3071,7 @@ public final class Switchboard extends serverSwitch {status[SwitchboardConstants.CRAWLJOB_SYNC].notifyAll();}}- setConfig(jobType + "_isPaused", "false");+ this.setConfig(jobType + "_isPaused", "false");}/**@@ -3110,7 +3092,7 @@ public final class Switchboard extends serverSwitch {in.queueEntry.updateStatus(Response.QUEUE_STATE_PARSING);Document[] documents = null;try {- documents = parseDocument(in.queueEntry);+ documents = this.parseDocument(in.queueEntry);} catch (final InterruptedException e ) {documents = null;} catch (final Exception e ) {@@ -3201,10 +3183,10 @@ public final class Switchboard extends serverSwitch {// check if the documents have valid urls; this is not a bug patch; it is possible that// i.e. the result of a feed parsing results in documents from domains which shall be filtered by the crawl profileif (response.profile() != null) {- ArrayList<Document> newDocs = new ArrayList<Document>();- for (Document doc: documents) {+ final ArrayList<Document> newDocs = new ArrayList<>();+ for (final Document doc: documents) {//doc.rewrite_dc_source(rewritePattern, "");- String rejectReason = this.crawlStacker.checkAcceptanceChangeable(doc.dc_source(), response.profile(), 1 /*depth is irrelevant here, we just make clear its not the start url*/);+ final String rejectReason = this.crawlStacker.checkAcceptanceChangeable(doc.dc_source(), response.profile(), 1 /*depth is irrelevant here, we just make clear its not the start url*/);if (rejectReason == null) {newDocs.add(doc);} else {@@ -3242,7 +3224,7 @@ public final class Switchboard extends serverSwitch {+ crawlerOriginUrlMustNotMatch.pattern());}} else {- for (Document d: documents) {+ for (final Document d: documents) {d.setDepth(response.depth());}@@ -3253,28 +3235,28 @@ public final class Switchboard extends serverSwitch {|| response.profile().isCrawlerAlwaysCheckMediaType() /* the crawler must always load resources to double-check the actual Media Type even on unsupported file extensions */;/* Handle media links */- for (Map.Entry<DigestURL, String> entry : Document.getImagelinks(documents).entrySet()) {+ for (final Map.Entry<DigestURL, String> entry : Document.getImagelinks(documents).entrySet()) {if (addAllLinksToCrawlStack|| (response.profile().indexMedia() && TextParser.supportsExtension(entry.getKey()) == null)) {hl.put(new AnchorURL(entry.getKey()), entry.getValue());}}- for (Map.Entry<DigestURL, String> entry : Document.getApplinks(documents).entrySet()) {+ for (final Map.Entry<DigestURL, String> entry : Document.getApplinks(documents).entrySet()) {if (addAllLinksToCrawlStack|| (response.profile().indexMedia() && TextParser.supportsExtension(entry.getKey()) == null)) {hl.put(new AnchorURL(entry.getKey()), entry.getValue());}}- for (Map.Entry<DigestURL, String> entry : Document.getVideolinks(documents).entrySet()) {+ for (final Map.Entry<DigestURL, String> entry : Document.getVideolinks(documents).entrySet()) {if (addAllLinksToCrawlStack|| (response.profile().indexMedia() && TextParser.supportsExtension(entry.getKey()) == null)) {hl.put(new AnchorURL(entry.getKey()), entry.getValue());}}- for (Map.Entry<DigestURL, String> entry : Document.getAudiolinks(documents).entrySet()) {+ for (final Map.Entry<DigestURL, String> entry : Document.getAudiolinks(documents).entrySet()) {if (addAllLinksToCrawlStack|| (response.profile().indexMedia() && TextParser.supportsExtension(entry.getKey()) == null)) {hl.put(new AnchorURL(entry.getKey()), entry.getValue());@@ -3285,7 +3267,7 @@ public final class Switchboard extends serverSwitch {MultiProtocolURL nextUrl;for ( final Map.Entry<AnchorURL, String> nextEntry : hl.entrySet() ) {// check for interruption- checkInterruption();+ this.checkInterruption();// process the next hyperlinknextUrl = nextEntry.getKey();@@ -3298,7 +3280,7 @@ public final class Switchboard extends serverSwitch {}// rewrite the url- String u0 = LibraryProvider.urlRewriter.apply(u);+ final String u0 = LibraryProvider.urlRewriter.apply(u);if (!u.equals(u0)) {this.log.info("REWRITE of url = \"" + u + "\" to \"" + u0 + "\"");u = u0;@@ -3307,7 +3289,7 @@ public final class Switchboard extends serverSwitch {//if (m.matches()) u = m.replaceAll("");// enqueue the hyperlink into the pre-notice-url db- int nextdepth = nextEntry.getValue() != null && nextEntry.getValue().equals(Document.CANONICAL_MARKER) ? response.depth() : response.depth() + 1; // canonical documents are on the same depth+ final int nextdepth = nextEntry.getValue() != null && nextEntry.getValue().equals(Document.CANONICAL_MARKER) ? response.depth() : response.depth() + 1; // canonical documents are on the same depthtry {this.crawlStacker.enqueueEntry(new Request(response.initiator(),@@ -3345,8 +3327,8 @@ public final class Switchboard extends serverSwitch {*/public IndexingQueueEntry condenseDocument(final IndexingQueueEntry in) {in.queueEntry.updateStatus(Response.QUEUE_STATE_CONDENSING);- CrawlProfile profile = in.queueEntry.profile();- String urls = in.queueEntry.url().toNormalform(true);+ final CrawlProfile profile = in.queueEntry.profile();+ final String urls = in.queueEntry.url().toNormalform(true);// check profile attributes which prevent indexing (while crawling is allowed)if (!profile.indexText() && !profile.indexMedia()) {@@ -3359,7 +3341,7 @@ public final class Switchboard extends serverSwitch {return new IndexingQueueEntry(in.queueEntry, in.documents, null);}// double check media by mime in case of no file extension- Classification.ContentDomain cd = Classification.getContentDomainFromMime(in.queueEntry.getMimeType());+ final Classification.ContentDomain cd = Classification.getContentDomainFromMime(in.queueEntry.getMimeType());// don't exclude contentdomain.app (from mime) to keep pdf word etc.if (cd == Classification.ContentDomain.IMAGE || cd == Classification.ContentDomain.VIDEO || cd == Classification.ContentDomain.AUDIO ) {this.log.info("Not Condensed Resource '" + urls + "': indexing of media not wanted by crawl profile");@@ -3375,7 +3357,7 @@ public final class Switchboard extends serverSwitch {}// check which files may take part in the indexing process- final List<Document> doclist = new ArrayList<Document>();+ final List<Document> doclist = new ArrayList<>();docloop: for (final Document document : in.documents) {if (document.indexingDenied() && profile.obeyHtmlRobotsNoindex() && !this.isIntranetMode()) {if (this.log.isInfo()) this.log.info("Not Condensed Resource '" + urls + "': denied by document-attached noindexing rule");@@ -3448,7 +3430,7 @@ public final class Switchboard extends serverSwitch {*/public IndexingQueueEntry webStructureAnalysis(final IndexingQueueEntry in) {in.queueEntry.updateStatus(Response.QUEUE_STATE_STRUCTUREANALYSIS);- for (Document document : in.documents) {+ for (final Document document : in.documents) {assert this.webStructure != null;assert in != null;assert in.queueEntry != null;@@ -3467,8 +3449,8 @@ public final class Switchboard extends serverSwitch {// the condenser may be null in case that an indexing is not wanted (there may be a no-indexing flag in the file)if ( in.condenser != null ) {for ( int i = 0; i < in.documents.length; i++ ) {- CrawlProfile profile = in.queueEntry.profile();- storeDocumentIndex(+ final CrawlProfile profile = in.queueEntry.profile();+ this.storeDocumentIndex(in.queueEntry,in.queueEntry.profile().collections(),in.documents[i],@@ -3510,7 +3492,7 @@ public final class Switchboard extends serverSwitch {if(this.crawler != null && queueEntry.profile() == this.crawler.defaultSurrogateProfile) {processCase = EventOrigin.SURROGATES;}- CrawlProfile profile = queueEntry.profile();+ final CrawlProfile profile = queueEntry.profile();if (condenser == null || (document.indexingDenied() && profile.obeyHtmlRobotsNoindex())) {//if (this.log.isInfo()) log.logInfo("Not Indexed Resource '" + queueEntry.url().toNormalform(false, true) + "': denied by rule in document, process case=" + processCase);@@ -3543,7 +3525,7 @@ public final class Switchboard extends serverSwitch {* One last posible filtering step before adding to index : using the eventual* profile Solr querie filters*/- final String profileSolrFilterError = checkCrawlProfileSolrFilters(profile, vector);+ final String profileSolrFilterError = this.checkCrawlProfileSolrFilters(profile, vector);if (profileSolrFilterError != null) {this.crawlQueues.errorURL.push(url, queueEntry.depth(), profile, FailCategory.FINAL_LOAD_CONTEXT,profileSolrFilterError + ", process case=" + processCase + ", profile name = "@@ -3553,7 +3535,7 @@ public final class Switchboard extends serverSwitch {}// STORE WORD INDEX- SolrInputDocument newEntry =+ final SolrInputDocument newEntry =this.index.storeDocument(url,profile,@@ -3564,7 +3546,7 @@ public final class Switchboard extends serverSwitch {condenser,searchEvent,sourceName,- getConfigBool(SwitchboardConstants.NETWORK_UNIT_DHT, false),+ this.getConfigBool(SwitchboardConstants.NETWORK_UNIT_DHT, false),this.getConfigBool(SwitchboardConstants.PROXY_TRANSPARENT_PROXY, false) ? "http://127.0.0.1:" + sb.getConfigInt(SwitchboardConstants.SERVER_PORT, 8090) : null,this.getConfig("crawler.http.acceptLanguage", null));final RSSFeed feed =@@ -3604,7 +3586,7 @@ public final class Switchboard extends serverSwitch {// update profiling infoif ( System.currentTimeMillis() - lastPPMUpdate > 20000 ) {// we don't want to do this too often- updateMySeed();+ this.updateMySeed();EventTracker.update(EventTracker.EClass.PPM, Long.valueOf(currentPPM()), true);lastPPMUpdate = System.currentTimeMillis();}@@ -3616,9 +3598,9 @@ public final class Switchboard extends serverSwitch {if ( initiatorPeer != null ) {// start a thread for receipt sending to avoid a blocking heretry {- SolrDocument sd = this.index.fulltext().getDefaultConfiguration().toSolrDocument(newEntry);+ final SolrDocument sd = this.index.fulltext().getDefaultConfiguration().toSolrDocument(newEntry);new Thread(new receiptSending(initiatorPeer, new URIMetadataNode(sd)), "sending receipt to " + ASCII.String(queueEntry.initiator())).start();- } catch (MalformedURLException ex) {+ } catch (final MalformedURLException ex) {this.log.info("malformed url: "+ex.getMessage());}}@@ -3693,7 +3675,7 @@ public final class Switchboard extends serverSwitch {final Map<String, Pattern> collections,final boolean doublecheck) {- List<DigestURL> urls = new ArrayList<DigestURL>();+ final List<DigestURL> urls = new ArrayList<>();// add the landing page to the index. should not load that again since it should be in the cacheif (url != null) {urls.add(url);@@ -3711,39 +3693,39 @@ public final class Switchboard extends serverSwitch {for (final Map.Entry<AnchorURL, String> entry : links.entrySet()) {urls.add(new DigestURL(entry.getKey(), (byte[]) null));}- addToIndex(urls, searchEvent, heuristicName, collections, doublecheck);+ this.addToIndex(urls, searchEvent, heuristicName, collections, doublecheck);}public void reload(final Collection<String> reloadURLStrings, final Map<String, Pattern> collections, final boolean doublecheck) {- final Collection<DigestURL> reloadURLs = new ArrayList<DigestURL>(reloadURLStrings.size());- Collection<String> deleteIDs = new ArrayList<String>(reloadURLStrings.size());- for (String u: reloadURLStrings) {+ final Collection<DigestURL> reloadURLs = new ArrayList<>(reloadURLStrings.size());+ final Collection<String> deleteIDs = new ArrayList<>(reloadURLStrings.size());+ for (final String u: reloadURLStrings) {DigestURL url;try {url = new DigestURL(u);reloadURLs.add(url);deleteIDs.add(ASCII.String(url.hash()));- } catch (MalformedURLException e) {+ } catch (final MalformedURLException e) {}}- remove(deleteIDs);+ this.remove(deleteIDs);if (doublecheck) this.index.fulltext().commit(false); // if not called here the double-cgeck in addToIndex will reject the indexing- addToIndex(reloadURLs, null, null, collections, doublecheck);+ this.addToIndex(reloadURLs, null, null, collections, doublecheck);}public void remove(final Collection<String> deleteIDs) {this.index.fulltext().remove(deleteIDs);- for (String id: deleteIDs) {- byte[] idh = ASCII.getBytes(id);+ for (final String id: deleteIDs) {+ final byte[] idh = ASCII.getBytes(id);this.crawlQueues.removeURL(idh);- try {Cache.delete(idh);} catch (IOException e) {}+ try {Cache.delete(idh);} catch (final IOException e) {}}}public void remove(final byte[] urlhash) {this.index.fulltext().remove(urlhash);this.crawlQueues.removeURL(urlhash);- try {Cache.delete(urlhash);} catch (IOException e) {}+ try {Cache.delete(urlhash);} catch (final IOException e) {}}public void stackURLs(final Collection<DigestURL> rootURLs, final CrawlProfile profile, final Set<DigestURL> successurls, final Map<DigestURL,String> failurls) {@@ -3767,13 +3749,13 @@ public final class Switchboard extends serverSwitch {}// do this concurrently- int threads = Math.min(rootURLs.size(), Math.min(50, Runtime.getRuntime().availableProcessors() * 2 + 1)); // it makes sense to have more threads than cores because those threads do a lot of waiting during IO+ final int threads = Math.min(rootURLs.size(), Math.min(50, Runtime.getRuntime().availableProcessors() * 2 + 1)); // it makes sense to have more threads than cores because those threads do a lot of waiting during IOthis.log.info("stackURLs: starting " + threads + " threads for " + rootURLs.size() + " root urls.");final BlockingQueue<DigestURL> rootURLsQueue = new ArrayBlockingQueue<>(rootURLs.size());- for (DigestURL u: rootURLs) try {rootURLsQueue.put(u);} catch (InterruptedException e) {}+ for (final DigestURL u: rootURLs) try {rootURLsQueue.put(u);} catch (final InterruptedException e) {}for (int i = 0; i < threads; i++) {final String name = "Switchboard.stackURLs-" + i + "-" + profile.handle();- Thread t = new Thread(name) {+ final Thread t = new Thread(name) {@Overridepublic void run() {DigestURL url;@@ -3813,11 +3795,11 @@ public final class Switchboard extends serverSwitch {*/public String stackUrl(CrawlProfile profile, DigestURL url) {- byte[] handle = ASCII.getBytes(profile.handle());+ final byte[] handle = ASCII.getBytes(profile.handle());// remove url from the index to be prepared for a re-crawlfinal byte[] urlhash = url.hash();- remove(urlhash);+ this.remove(urlhash);// because the removal is done concurrenlty, it is possible that the crawl// stacking may fail because of double occurrences of that url. Therefore// we must wait here until the url has actually disappeared@@ -3851,7 +3833,7 @@ public final class Switchboard extends serverSwitch {}// remove the document from the error-db- Set<String> hosthashes = new HashSet<String>();+ final Set<String> hosthashes = new HashSet<>();hosthashes.add(url.hosthash());this.crawlQueues.errorURL.removeHosts(hosthashes);this.index.fulltext().remove(urlhash);@@ -3925,13 +3907,13 @@ public final class Switchboard extends serverSwitch {* @throws Parser.Failure*/public void addToIndex(final Collection<DigestURL> urls, final SearchEvent searchEvent, final String heuristicName, final Map<String, Pattern> collections, final boolean doublecheck) {- Map<String, DigestURL> urlmap = new HashMap<String, DigestURL>();- for (DigestURL url: urls) urlmap.put(ASCII.String(url.hash()), url);+ final Map<String, DigestURL> urlmap = new HashMap<>();+ for (final DigestURL url: urls) urlmap.put(ASCII.String(url.hash()), url);if (searchEvent != null) {- for (String id: urlmap.keySet()) searchEvent.addHeuristic(ASCII.getBytes(id), heuristicName, true);+ for (final String id: urlmap.keySet()) searchEvent.addHeuristic(ASCII.getBytes(id), heuristicName, true);}- final List<Request> requests = new ArrayList<Request>();- for (Map.Entry<String, DigestURL> e: urlmap.entrySet()) {+ final List<Request> requests = new ArrayList<>();+ for (final Map.Entry<String, DigestURL> e: urlmap.entrySet()) {final String urlName = e.getValue().toNormalform(true);if (doublecheck) {if (this.index.exists(e.getKey())) {@@ -3952,9 +3934,9 @@ public final class Switchboard extends serverSwitch {new Thread() {@Overridepublic void run() {- for (Request request: requests) {- DigestURL url = request.url();- String urlName = url.toNormalform(true);+ for (final Request request: requests) {+ final DigestURL url = request.url();+ final String urlName = url.toNormalform(true);Thread.currentThread().setName("Switchboard.addToIndex:" + urlName);try {final Response response = Switchboard.this.loader.load(request, CacheStrategy.IFFRESH, BlacklistType.CRAWLER, ClientIdentification.yacyIntranetCrawlerAgent);@@ -3980,7 +3962,7 @@ public final class Switchboard extends serverSwitch {searchEvent == null ? 0 : searchEvent.query.timezoneOffset);ResultImages.registerImages(url, document, true);Switchboard.this.webStructure.generateCitationReference(url, document);- storeDocumentIndex(+ Switchboard.this.storeDocumentIndex(response,collections,document,@@ -4009,11 +3991,11 @@ public final class Switchboard extends serverSwitch {* @param asglobal true adds the url to global crawl queue (for remote crawling), false to the local crawler*/public void addToCrawler(final Collection<DigestURL> urls, final boolean asglobal) {- Map<String, DigestURL> urlmap = new HashMap<String, DigestURL>();- for (DigestURL url: urls) urlmap.put(ASCII.String(url.hash()), url);- for (Map.Entry<String, DigestURL> e: urlmap.entrySet()) {+ final Map<String, DigestURL> urlmap = new HashMap<>();+ for (final DigestURL url: urls) urlmap.put(ASCII.String(url.hash()), url);+ for (final Map.Entry<String, DigestURL> e: urlmap.entrySet()) {if (this.index.exists(e.getKey())) continue; // double- DigestURL url = e.getValue();+ final DigestURL url = e.getValue();final Request request = this.loader.request(url, true, true);final CrawlProfile profile = this.crawler.get(ASCII.getBytes(request.profileHandle()));String acceptedError = this.crawlStacker.checkAcceptanceChangeable(url, profile, 0);@@ -4101,8 +4083,8 @@ public final class Switchboard extends serverSwitch {}// authorization in case that there is no account stored- final String adminAccountUserName = getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin");- final String adminAccountBase64MD5 = getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "");+ final String adminAccountUserName = this.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin");+ final String adminAccountBase64MD5 = this.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "");if ( adminAccountBase64MD5.isEmpty() ) {this.adminAuthenticationLastAccess = System.currentTimeMillis();return 2; // no password stored; this should not happen for older peers@@ -4115,14 +4097,14 @@ public final class Switchboard extends serverSwitch {// authorization for localhost, only if flag is set to grant localhost access as adminfinal boolean accessFromLocalhost = requestHeader.accessFromLocalhost();- if (accessFromLocalhost && getConfigBool(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST, false)) {+ if (accessFromLocalhost && this.getConfigBool(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST, false)) {this.adminAuthenticationLastAccess = System.currentTimeMillis();return 3; // soft-authenticated for localhost}// get the authorization string from the headerfinal String realmProp = (requestHeader.get(RequestHeader.AUTHORIZATION, "")).trim();- String realmValue = realmProp.isEmpty() ? null : realmProp.substring(6); // take out "BASIC "+ final String realmValue = realmProp.isEmpty() ? null : realmProp.substring(6); // take out "BASIC "// authorization with admin keyword in configurationif ( realmValue == null || realmValue.isEmpty() ) {@@ -4149,7 +4131,7 @@ public final class Switchboard extends serverSwitch {}// authorization by encoded password, only for localhost access- String pass = Base64Order.standardCoder.encodeString(adminAccountUserName + ":" + adminAccountBase64MD5);+ final String pass = Base64Order.standardCoder.encodeString(adminAccountUserName + ":" + adminAccountBase64MD5);if ( accessFromLocalhost && (pass.equals(realmValue)) ) { // assume realmValue as is in cfgthis.adminAuthenticationLastAccess = System.currentTimeMillis();return 3; // soft-authenticated for localhost@@ -4165,7 +4147,7 @@ public final class Switchboard extends serverSwitch {if (adminAccountBase64MD5.startsWith("MD5:")) {// handle new option adminAccountBase64MD5="MD5:xxxxxxx" = encodeMD5Hex ("adminname:peername:password")String realmtmp = Base64Order.standardCoder.decodeString(realmValue); //decode to clear text- int i = realmtmp.indexOf(':');+ final int i = realmtmp.indexOf(':');if (i >= 3) { // put peer name in realmValue (>3 is ok to skip "MD5:" and usernames are min 4 characters, in basic auth realm "user:pwd")realmtmp = realmtmp.substring(0, i + 1) + sb.getConfig(SwitchboardConstants.ADMIN_REALM,"YaCy") + ":" + realmtmp.substring(i + 1);@@ -4204,7 +4186,7 @@ public final class Switchboard extends serverSwitch {*/public boolean verifyAuthentication(final RequestHeader header) {// handle access rights- switch ( adminAuthenticated(header) ) {+ switch ( this.adminAuthenticated(header) ) {case 0: // wrong password given//try { Thread.sleep(3000); } catch (final InterruptedException e) { } // prevent brute-forcereturn false;@@ -4222,7 +4204,7 @@ public final class Switchboard extends serverSwitch {}public String dhtShallTransfer() {- final String cautionCause = onlineCaution();+ final String cautionCause = this.onlineCaution();if ( cautionCause != null ) {return "online caution for " + cautionCause + ", dht transmission";}@@ -4238,10 +4220,10 @@ public final class Switchboard extends serverSwitch {if ( this.peers.noDHTActivity() ) {return "no DHT distribution: network too small";}- if ( !getConfigBool(SwitchboardConstants.NETWORK_UNIT_DHT, true) ) {+ if ( !this.getConfigBool(SwitchboardConstants.NETWORK_UNIT_DHT, true) ) {return "no DHT distribution: disabled by network.unit.dht";}- if ( getConfig(SwitchboardConstants.INDEX_DIST_ALLOW, "false").equalsIgnoreCase("false") ) {+ if ( this.getConfig(SwitchboardConstants.INDEX_DIST_ALLOW, "false").equalsIgnoreCase("false") ) {return "no DHT distribution: not enabled (per setting)";}final Segment indexSegment = this.index;@@ -4249,17 +4231,17 @@ public final class Switchboard extends serverSwitch {return "no DHT distribution: not enough words - wordIndex.size() = "+ indexSegment.RWICount();}- if ( (getConfig(SwitchboardConstants.INDEX_DIST_ALLOW_WHILE_CRAWLING, "false").equalsIgnoreCase("false")) && (!this.crawlQueues.noticeURL.isEmptyLocal()) ) {+ if ( (this.getConfig(SwitchboardConstants.INDEX_DIST_ALLOW_WHILE_CRAWLING, "false").equalsIgnoreCase("false")) && (!this.crawlQueues.noticeURL.isEmptyLocal()) ) {return "no DHT distribution: crawl in progress: noticeURL.stackSize() = "+ this.crawlQueues.noticeURL.size()+ ", sbQueue.size() = "- + getIndexingProcessorsQueueSize();+ + this.getIndexingProcessorsQueueSize();}- if ( (getConfig(SwitchboardConstants.INDEX_DIST_ALLOW_WHILE_INDEXING, "false").equalsIgnoreCase("false")) && (getIndexingProcessorsQueueSize() > 1) ) {+ if ( (this.getConfig(SwitchboardConstants.INDEX_DIST_ALLOW_WHILE_INDEXING, "false").equalsIgnoreCase("false")) && (this.getIndexingProcessorsQueueSize() > 1) ) {return "no DHT distribution: indexing in progress: noticeURL.stackSize() = "+ this.crawlQueues.noticeURL.size()+ ", sbQueue.size() = "- + getIndexingProcessorsQueueSize();+ + this.getIndexingProcessorsQueueSize();}return null; // this means; yes, please do dht transfer@@ -4269,7 +4251,7 @@ public final class Switchboard extends serverSwitch {if ( this.dhtDispatcher == null ) {return false;}- final String rejectReason = dhtShallTransfer();+ final String rejectReason = this.dhtShallTransfer();if ( rejectReason != null ) {if ( this.log.isFine() ) {this.log.fine(rejectReason);@@ -4372,7 +4354,7 @@ public final class Switchboard extends serverSwitch {}// add all pages to the index- addAllToIndex(url, links, searchEvent, "site", CrawlProfile.collectionParser("site"), true);+ Switchboard.this.addAllToIndex(url, links, searchEvent, "site", CrawlProfile.collectionParser("site"), true);}} catch (final Throwable e ) {ConcurrentLog.logException(e);@@ -4401,13 +4383,13 @@ public final class Switchboard extends serverSwitch {// result might be rich metadata, try to get outbout links directly from resultSet<DigestURL> urls;- Iterator<String> outlinkit = URIMetadataNode.getLinks(resulturl, false);+ final Iterator<String> outlinkit = URIMetadataNode.getLinks(resulturl, false);if (outlinkit.hasNext()) {- urls = new HashSet<DigestURL>();+ urls = new HashSet<>();while (outlinkit.hasNext()) {try {urls.add(new DigestURL(outlinkit.next()));- } catch (MalformedURLException ex) { }+ } catch (final MalformedURLException ex) { }}} else { // otherwise get links from loaderurls = null;@@ -4418,10 +4400,10 @@ public final class Switchboard extends serverSwitch {if (links != null) {if (links.size() < 1000) { // limit to 1000 to skip large index pagesfinal Iterator<AnchorURL> i = links.keySet().iterator();- if (urls == null) urls = new HashSet<DigestURL>();+ if (urls == null) urls = new HashSet<>();while (i.hasNext()) {- DigestURL url = i.next();- boolean islocal = (url.getHost() == null && startUrl.getHost() == null) || (url.getHost() != null && startUrl.getHost() != null && url.getHost().contentEquals(startUrl.getHost()));+ final DigestURL url = i.next();+ final boolean islocal = (url.getHost() == null && startUrl.getHost() == null) || (url.getHost() != null && startUrl.getHost() != null && url.getHost().contentEquals(startUrl.getHost()));// add all external links or links to different page to crawlerif ( !islocal ) {// || (!startUrl.getPath().endsWith(url.getPath()))) {urls.add(url);@@ -4433,7 +4415,7 @@ public final class Switchboard extends serverSwitch {}if (urls != null && urls.size() > 0) {final boolean globalcrawljob = Switchboard.this.getConfigBool(SwitchboardConstants.HEURISTIC_SEARCHRESULTS_CRAWLGLOBAL,false);- addToCrawler(urls, globalcrawljob);+ Switchboard.this.addToCrawler(urls, globalcrawljob);}}}.start();@@ -4491,7 +4473,7 @@ public final class Switchboard extends serverSwitch {+ feedName+ "' rss feed");// add all pages to the index- addAllToIndex(null, links, searchEvent, feedName, CrawlProfile.collectionParser("rss"), true);+ Switchboard.this.addAllToIndex(null, links, searchEvent, feedName, CrawlProfile.collectionParser("rss"), true);}} catch (final Throwable e ) {} finally {@@ -4528,17 +4510,17 @@ public final class Switchboard extends serverSwitch {private static long indeSizeCache = 0;private static long indexSizeTime = 0;public void updateMySeed() {- this.peers.mySeed().put(Seed.PORT, Integer.toString(getPublicPort(SwitchboardConstants.SERVER_PORT, 8090)));+ this.peers.mySeed().put(Seed.PORT, Integer.toString(this.getPublicPort(SwitchboardConstants.SERVER_PORT, 8090)));//the speed of indexing (pages/minute) of the peerfinal long uptime = (System.currentTimeMillis() - this.startupTime) / 1000;- Seed mySeed = this.peers.mySeed();+ final Seed mySeed = this.peers.mySeed();mySeed.put(Seed.ISPEED, Integer.toString(currentPPM()));- mySeed.put(Seed.RSPEED, Float.toString(averageQPM()));+ mySeed.put(Seed.RSPEED, Float.toString(this.averageQPM()));mySeed.put(Seed.UPTIME, Long.toString(uptime / 60)); // the number of minutes that the peer is up in minutes/day (moving average MA30)- long t = System.currentTimeMillis();+ final long t = System.currentTimeMillis();if (t - indexSizeTime > 60000) {indeSizeCache = sb.index.fulltext().collectionSize();indexSizeTime = t;@@ -4553,15 +4535,15 @@ public final class Switchboard extends serverSwitch {mySeed.setFlagDirectConnect(true);mySeed.setLastSeenUTC();mySeed.put(Seed.UTC, GenericFormatter.UTCDiffString());- mySeed.setFlagAcceptRemoteCrawl(getConfigBool(SwitchboardConstants.CRAWLJOB_REMOTE, false));- mySeed.setFlagAcceptRemoteIndex(getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW, true));- mySeed.setFlagSSLAvailable(this.getHttpServer() != null && this.getHttpServer().withSSL() && getConfigBool("server.https", false));- if (mySeed.getFlagSSLAvailable()) mySeed.put(Seed.PORTSSL, Integer.toString(getPublicPort(SwitchboardConstants.SERVER_SSLPORT, 8443)));+ mySeed.setFlagAcceptRemoteCrawl(this.getConfigBool(SwitchboardConstants.CRAWLJOB_REMOTE, false));+ mySeed.setFlagAcceptRemoteIndex(this.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW, true));+ mySeed.setFlagSSLAvailable(this.getHttpServer() != null && this.getHttpServer().withSSL() && this.getConfigBool("server.https", false));+ if (mySeed.getFlagSSLAvailable()) mySeed.put(Seed.PORTSSL, Integer.toString(this.getPublicPort(SwitchboardConstants.SERVER_SSLPORT, 8443)));// set local ips- String staticIP = this.getConfig(SwitchboardConstants.SERVER_STATICIP, "");+ final String staticIP = this.getConfig(SwitchboardConstants.SERVER_STATICIP, "");if (staticIP.length() > 0) mySeed.setIP(staticIP);- Set<String> publicips = myPublicIPs();+ final Set<String> publicips = this.myPublicIPs();if (!mySeed.clash(publicips)) mySeed.setIPs(publicips);}@@ -4573,7 +4555,7 @@ public final class Switchboard extends serverSwitch {Network.log.info("BOOTSTRAP: " + sc + " seeds known from previous run, concurrently starting seedlist loader");// - use the superseed to further fill up the seedDB- AtomicInteger scc = new AtomicInteger(0);+ final AtomicInteger scc = new AtomicInteger(0);int c = 0;while ( true ) {if ( Thread.currentThread().isInterrupted() ) {@@ -4585,18 +4567,18 @@ public final class Switchboard extends serverSwitch {}c++;if ( seedListFileURL.startsWith("http://") || seedListFileURL.startsWith("https://") ) {- this.peers.loadSeedListConcurrently(seedListFileURL, scc, (int) getConfigLong("bootstrapLoadTimeout", 20000), c > 0);+ this.peers.loadSeedListConcurrently(seedListFileURL, scc, (int) this.getConfigLong("bootstrapLoadTimeout", 20000), c > 0);}}}public void initRemoteProxy() {// reading the proxy host name- final String host = getConfig("remoteProxyHost", "").trim();+ final String host = this.getConfig("remoteProxyHost", "").trim();// reading the proxy host portint port;try {- port = Integer.parseInt(getConfig("remoteProxyPort", "3128"));+ port = Integer.parseInt(this.getConfig("remoteProxyPort", "3128"));} catch (final NumberFormatException e ) {port = 3128;}@@ -4604,13 +4586,13 @@ public final class Switchboard extends serverSwitch {// create new configProxySettings.port = port;ProxySettings.host = host;- ProxySettings.setProxyUse4HTTP(ProxySettings.host != null && ProxySettings.host.length() > 0 && getConfigBool("remoteProxyUse", false));- ProxySettings.setProxyUse4HTTPS(getConfig("remoteProxyUse4SSL", "true").equalsIgnoreCase("true"));- ProxySettings.user = getConfig("remoteProxyUser", "").trim();- ProxySettings.password = getConfig("remoteProxyPwd", "").trim();+ ProxySettings.setProxyUse4HTTP(ProxySettings.host != null && ProxySettings.host.length() > 0 && this.getConfigBool("remoteProxyUse", false));+ ProxySettings.setProxyUse4HTTPS(this.getConfig("remoteProxyUse4SSL", "true").equalsIgnoreCase("true"));+ ProxySettings.user = this.getConfig("remoteProxyUser", "").trim();+ ProxySettings.password = this.getConfig("remoteProxyPwd", "").trim();// determining addresses for which the remote proxy should not be used- final String remoteProxyNoProxy = getConfig("remoteProxyNoProxy", "").trim();+ final String remoteProxyNoProxy = this.getConfig("remoteProxyNoProxy", "").trim();ProxySettings.noProxy = CommonPattern.COMMA.split(remoteProxyNoProxy);// trim split entriesint i = 0;@@ -4670,7 +4652,7 @@ public final class Switchboard extends serverSwitch {final int shutdownPort;if ((shutdownPort = this.getConfigInt(SwitchboardConstants.SERVER_SHUTDOWNPORT, 0)) > 0) {// init thread to listen to a shutdown port - to receive a shutdown signal- Thread shutdownThread = new Thread("Switchboard.waitForShutdown") {+ final Thread shutdownThread = new Thread("Switchboard.waitForShutdown") {@Overridepublic void run() {ServerSocket ss = null;@@ -4678,26 +4660,26 @@ public final class Switchboard extends serverSwitch {shutdownloop: while (true) {ss = new ServerSocket(shutdownPort, 0, InetAddress.getLoopbackAddress());- Socket shSocket = ss.accept();+ final Socket shSocket = ss.accept();- InputStream in = shSocket.getInputStream();- BufferedReader inreader = new BufferedReader(new InputStreamReader(in));- String cmd = inreader.readLine(); // read a input line to check for command shutdown+ final InputStream in = shSocket.getInputStream();+ final BufferedReader inreader = new BufferedReader(new InputStreamReader(in));+ final String cmd = inreader.readLine(); // read a input line to check for command shutdown// check for shutdown command, accept e.g. http://localhost:8009/shutdown connect with input line "GET /shutdown HTTP/1.1"if (cmd != null && !cmd.isEmpty()) {if (cmd.contains("shutdown")) {if (cmd.contains("HTTP")) { // write a min. http response- OutputStream out = shSocket.getOutputStream();+ final OutputStream out = shSocket.getOutputStream();out.write(UTF8.getBytes("HTTP/1.1 200 OK"));out.write(serverCore.CRLF);out.close();}ss.close();- terminate("shutdown signal received on shutdown port");+ Switchboard.this.terminate("shutdown signal received on shutdown port");} else if (cmd.contains("restart")) {if (cmd.contains("HTTP")) { // write a min. http response- OutputStream out = shSocket.getOutputStream();+ final OutputStream out = shSocket.getOutputStream();out.write(UTF8.getBytes("HTTP/1.1 200 OK"));out.write(serverCore.CRLF);out.close();@@ -4709,12 +4691,12 @@ public final class Switchboard extends serverSwitch {}ss.close(); // we don't want to accept any additional input (abort/disconnect if not expected input)}- } catch (IOException ex) {+ } catch (final IOException ex) {} finally {if (ss != null) {try {ss.close();- } catch (IOException ex) { }+ } catch (final IOException ex) { }}}}