diff options
| -rw-r--r-- | defaults/yacy.init | 3 | ||||
| -rw-r--r-- | source/net/yacy/http/YaCyHttpServer.java | 3 | ||||
| -rw-r--r-- | source/net/yacy/search/SwitchboardConstants.java | 187 | ||||
| -rw-r--r-- | source/net/yacy/server/serverSwitch.java | 108 | ||||
| -rw-r--r-- | source/net/yacy/yacy.java | 3 |
5 files changed, 156 insertions, 148 deletions
diff --git a/defaults/yacy.init b/defaults/yacy.init index d1622ba73..4bd2d8fa0 100644 --- a/defaults/yacy.init +++ b/defaults/yacy.init @@ -10,6 +10,9 @@ # port number where the server should bind to
port = 8090
+# The network interface this connector binds to as an IP address or a hostname.
+host = 0.0.0.0
+
# optinal ssl port (https port) the server should bind to
port.ssl = 8443
diff --git a/source/net/yacy/http/YaCyHttpServer.java b/source/net/yacy/http/YaCyHttpServer.java index 4018b2c17..4d77254f3 100644 --- a/source/net/yacy/http/YaCyHttpServer.java +++ b/source/net/yacy/http/YaCyHttpServer.java @@ -68,6 +68,7 @@ public class YaCyHttpServer { /** * @param port TCP Port to listen for http requests + * @param host The network interface this connector binds to as an IP address or a hostname. */ public YaCyHttpServer(final int port, final String host) { final Switchboard sb = Switchboard.getSwitchboard(); @@ -96,7 +97,7 @@ public class YaCyHttpServer { if (useSSL) { final SslContextFactory sslContextFactory = new SslContextFactory.Server(); - final SSLContext sslContext = initSslContext(sb); + final SSLContext sslContext = this.initSslContext(sb); if (sslContext != null) { final int sslport = sb.getConfigInt(SwitchboardConstants.SERVER_SSLPORT, 8443); diff --git a/source/net/yacy/search/SwitchboardConstants.java b/source/net/yacy/search/SwitchboardConstants.java index 3cb82d58b..3a168a269 100644 --- a/source/net/yacy/search/SwitchboardConstants.java +++ b/source/net/yacy/search/SwitchboardConstants.java @@ -59,6 +59,7 @@ public final class SwitchboardConstants { // server settings public static final String SERVER_PORT = "port"; // port for the http server + public static final String SERVER_HOST = "host"; // host for the http server public static final String SERVER_SSLPORT = "port.ssl"; // port for https public static final String SERVER_SHUTDOWNPORT = "port.shutdown"; // local port to listen for a shutdown signal (0 <= disabled) public static final String SERVER_STATICIP = "staticIP"; // static IP of http server @@ -110,7 +111,7 @@ public final class SwitchboardConstants { public static final String CRAWLJOB_LOCAL_CRAWL = "50_localcrawl"; public static final String CRAWLJOB_LOCAL_CRAWL_IDLESLEEP = "50_localcrawl_idlesleep"; public static final String CRAWLJOB_LOCAL_CRAWL_BUSYSLEEP = "50_localcrawl_busysleep"; - public static final String CRAWLJOB_LOCAL_CRAWL_LOADPREREQ = "50_localcrawl_loadprereq"; + public static final String CRAWLJOB_LOCAL_CRAWL_LOADPREREQ = "50_localcrawl_loadprereq"; // 55_autocrawl /** * <p><code>public static final String <string>CRAWLJOB_AUTOCRAWL</strong> = "55_autocrawl"</code></p> @@ -206,7 +207,7 @@ public final class SwitchboardConstants { public static final String INDEX_RECEIVE_ALLOW = "allowReceiveIndex"; public static final String INDEX_RECEIVE_ALLOW_SEARCH = "allowReceiveIndex.search"; public static final String INDEX_RECEIVE_BLOCK_BLACKLIST = "indexReceiveBlockBlacklist"; - + /** * <p><code>public static final String <strong>INDEX_DIST_ALLOW_WHILE_CRAWLING</strong> = "allowDistributeIndexWhileCrawling"</code></p> * <p>Name of the setting whether Index Distribution shall be allowed while crawling is in progress, i.e. @@ -250,7 +251,7 @@ public final class SwitchboardConstants { public static final String AUTOCRAWL_QUERY = "autocrawl.query"; public static final String AUTOCRAWL_DEEP_DEPTH = "autocrawl.deep.depth"; public static final String AUTOCRAWL_SHALLOW_DEPTH = "autocrawl.shallow.depth"; - + ////////////////////////////////////////////////////////////////////////////////////////////// // Cluster settings @@ -261,10 +262,10 @@ public final class SwitchboardConstants { public static final String CLUSTER_MODE_PUBLIC_PEER = "publicpeer"; public static final String CLUSTER_MODE_PRIVATE_PEER = "privatepeer"; public static final String CLUSTER_PEERS_IPPORT = "cluster.peers.ipport"; - + /** Key of the global HTTP Referrer policy delivered by meta tag */ public static final String REFERRER_META_POLICY = "referrer.meta.policy"; - + /** Default value for the global HTTP Referrer policy delivered by meta tag */ public static final String REFERRER_META_POLICY_DEFAULT = "origin-when-cross-origin"; @@ -278,25 +279,25 @@ public final class SwitchboardConstants { public static final String REMOTESEARCH_RESULT_STORE = "remotesearch.result.store"; // add remote results to local index /** Maximum size allowed (in kbytes) for a remote document result to be stored to local index */ public static final String REMOTESEARCH_RESULT_STORE_MAXSIZE= "remotesearch.result.store.maxsize"; - + /** Setting key to configure the maximum system load allowing remote RWI searches */ public static final String REMOTESEARCH_MAXLOAD_RWI = "remotesearch.maxload.rwi"; - + /** Default maximum system load allowing remote RWI searches */ - public static final float REMOTESEARCH_MAXLOAD_RWI_DEFAULT = 2.0f * (float) Runtime.getRuntime().availableProcessors(); - + public static final float REMOTESEARCH_MAXLOAD_RWI_DEFAULT = 2.0f * Runtime.getRuntime().availableProcessors(); + /** Setting key to configure the maximum system load allowing remote Solr searches */ public static final String REMOTESEARCH_MAXLOAD_SOLR = "remotesearch.maxload.solr"; - + /** Default maximum system load allowing remote Solr searches */ - public static final float REMOTESEARCH_MAXLOAD_SOLR_DEFAULT = (float) Runtime.getRuntime().availableProcessors(); - + public static final float REMOTESEARCH_MAXLOAD_SOLR_DEFAULT = Runtime.getRuntime().availableProcessors(); + /** Key of the setting controlling whether https should be preferred for remote searches, when available on the target peer */ public static final String REMOTESEARCH_HTTPS_PREFERRED = "remotesearch.https.preferred"; - + /** Default setting value controlling whether https should be preferred for remote searches, when available on the target peer */ public static final boolean REMOTESEARCH_HTTPS_PREFERRED_DEFAULT = false; - + /** * Setting key to configure whether responses from remote Solr instances * should be binary encoded : @@ -307,23 +308,23 @@ public final class SwitchboardConstants { * </ul> */ public static final String REMOTE_SOLR_BINARY_RESPONSE_ENABLED = "remote.solr.binaryResponse.enabled"; - + /** Default configuration setting for remote Solr responses binary encoding */ public static final boolean REMOTE_SOLR_BINARY_RESPONSE_ENABLED_DEFAULT = true; /** Key of the setting controlling whether to use or not remote Solr server(s) */ public static final String FEDERATED_SERVICE_SOLR_INDEXING_ENABLED = "federated.service.solr.indexing.enabled"; - + /** Default setting value controlling whether to use or not remote Solr server(s) */ public static final boolean FEDERATED_SERVICE_SOLR_INDEXING_ENABLED_DEFAULT = false; - + public static final String FEDERATED_SERVICE_SOLR_INDEXING_URL = "federated.service.solr.indexing.url"; public static final String FEDERATED_SERVICE_SOLR_INDEXING_SHARDING = "federated.service.solr.indexing.sharding"; public static final String FEDERATED_SERVICE_SOLR_INDEXING_LAZY = "federated.service.solr.indexing.lazy"; public static final String FEDERATED_SERVICE_SOLR_INDEXING_TIMEOUT = "federated.service.solr.indexing.timeout"; public static final String FEDERATED_SERVICE_SOLR_INDEXING_WRITEENABLED = "federated.service.solr.indexing.writeEnabled"; - - /** Setting key controlling whether a self-signed certificate is acceptable from a remote Solr instance requested with authentication credentials. + + /** Setting key controlling whether a self-signed certificate is acceptable from a remote Solr instance requested with authentication credentials. * This has no impact on connections to remote Solr instances used in p2p search for which self-signed certificates are always accepted. */ public static final String FEDERATED_SERVICE_SOLR_INDEXING_AUTHENTICATED_ALLOW_SELF_SIGNED = "federated.service.solr.indexing.authenticated.allowSelfSigned"; @@ -332,10 +333,10 @@ public final class SwitchboardConstants { /** Key of the setting controlling whether to use or not an embedded Solr instance */ public static final String CORE_SERVICE_FULLTEXT = "core.service.fulltext"; - + /** Default setting value controlling whether to use or not an embedded Solr instance */ public static final boolean CORE_SERVICE_FULLTEXT_DEFAULT = true; - + public static final String CORE_SERVICE_RWI = "core.service.rwi.tmp"; public static final String CORE_SERVICE_CITATION = "core.service.citation.tmp"; public static final String CORE_SERVICE_WEBGRAPH = "core.service.webgraph.tmp"; @@ -349,44 +350,44 @@ public final class SwitchboardConstants { public static final String CRAWLER_MAX_SAME_HOST_IN_QUEUE = "crawler.MaxSameHostInQueue"; public static final String CRAWLER_FOLLOW_REDIRECTS = "crawler.http.FollowRedirects"; // ignore the target url and follow to the redirect public static final String CRAWLER_RECORD_REDIRECTS = "crawler.http.RecordRedirects"; // record the ignored redirected page to the index store - + public static final String CRAWLER_USER_AGENT_NAME = "crawler.userAgent.name"; public static final String CRAWLER_USER_AGENT_STRING = "crawler.userAgent.string"; public static final String CRAWLER_USER_AGENT_MINIMUMDELTA = "crawler.userAgent.minimumdelta"; public static final String CRAWLER_USER_AGENT_CLIENTTIMEOUT = "crawler.userAgent.clienttimeout"; - + /** Key of the setting controlling the maximum time to wait for each wkhtmltopdf call when rendering PDF snapshots */ public static final String SNAPSHOTS_WKHTMLTOPDF_TIMEOUT = "snapshots.wkhtmltopdf.timeout"; - + /** Default maximum time in seconds to wait for each wkhtmltopdf call when rendering PDF snapshots*/ public static final long SNAPSHOTS_WKHTMLTOPDF_TIMEOUT_DEFAULT = 30; - + /* --- debug flags --- */ - + /** when set to true : do not use the local dht/rwi index (which is not done if we do remote searches) */ public static final String DEBUG_SEARCH_LOCAL_DHT_OFF = "debug.search.local.dht.off"; - + /** when set to true : do not use local solr index */ public static final String DEBUG_SEARCH_LOCAL_SOLR_OFF = "debug.search.local.solr.off"; - + /** when set to true : do not use remote dht/rwi */ public static final String DEBUG_SEARCH_REMOTE_DHT_OFF = "debug.search.remote.dht.off"; - + /** when set to true : do not use remote solr indexes */ public static final String DEBUG_SEARCH_REMOTE_SOLR_OFF = "debug.search.remote.solr.off"; - + /** when set to true : do not use dht, search local peer in a shortcut to the own server */ public static final String DEBUG_SEARCH_REMOTE_DHT_TESTLOCAL= "debug.search.remote.dht.testlocal"; - + /** when set to true : do not use dht, search local peer in a shortcut to the own server */ public static final String DEBUG_SEARCH_REMOTE_SOLR_TESTLOCAL= "debug.search.remote.solr.testlocal"; - + /** Key of the setting controlling whether text snippets statistics should be computed */ public static final String DEBUG_SNIPPETS_STATISTICS_ENABLED = "debug.snippets.statistics.enabled"; - + /** Default value for the setting controlling whether text snippets statistics should be computed */ public static final boolean DEBUG_SNIPPETS_STATISTICS_ENABLED_DEFAULT = false; - + /** * <p><code>public static final String <strong>WORDCACHE_MAX_COUNT</strong> = "wordCacheMaxCount"</code></p> * <p>Name of the setting how many words the word-cache (or DHT-Out cache) shall contain maximal. Indexing pages if the @@ -403,7 +404,7 @@ public final class SwitchboardConstants { /** Key of the setting configuring the bluelist file name */ public static final String LIST_BLUE = "plasmaBlueList"; - + /** Default bluelist file name */ public static final String LIST_BLUE_DEFAULT = null; public static final String LIST_BADWORDS_DEFAULT = "yacy.badwords"; @@ -417,19 +418,19 @@ public final class SwitchboardConstants { */ public static final String HTCACHE_PATH = "proxyCache"; public static final String HTCACHE_PATH_DEFAULT = "DATA/HTCACHE"; - + /** Key of the setting configuring the cache synchronization */ public static final String HTCACHE_COMPRESSION_LEVEL = "proxyCache.compressionLevel"; - + /** Default compression level for cached content */ public static final int HTCACHE_COMPRESSION_LEVEL_DEFAULT = Deflater.BEST_COMPRESSION; - + /** Key of the setting configuring Cache synchronization lock timeout on getContent/store operations*/ public static final String HTCACHE_SYNC_LOCK_TIMEOUT = "proxyCache.sync.lockTimeout"; - + /** Default timeout value (in milliseconds) for acquiring a synchronization lock on getContent/store Cache operations */ public static final long HTCACHE_SYNC_LOCK_TIMEOUT_DEFAULT = 2000; - + public static final String RELEASE_PATH = "releases"; public static final String RELEASE_PATH_DEFAULT = "DATA/RELEASE"; @@ -440,12 +441,12 @@ public final class SwitchboardConstants { public static final String DICTIONARY_SOURCE_PATH = "dictionaries"; public static final String DICTIONARY_SOURCE_PATH_DEFAULT = "DATA/DICTIONARIES"; - - /** Setting key for a set of comma separated vocabulary names whose terms should only be matched - * from linked data types annotations in documents (with microdata, RDFa, microformats...) + + /** Setting key for a set of comma separated vocabulary names whose terms should only be matched + * from linked data types annotations in documents (with microdata, RDFa, microformats...) * instead of cleartext words */ public static final String VOCABULARIES_MATCH_LINKED_DATA_NAMES = "vocabularies.matchLinkedData.names"; - + public static final String CLASSIFICATION_SOURCE_PATH = "classification"; public static final String CLASSIFICATION_SOURCE_PATH_DEFAULT = "DATA/CLASSIFICATION"; @@ -488,35 +489,35 @@ public final class SwitchboardConstants { */ public static final String WORK_PATH = "workPath"; public static final String WORK_PATH_DEFAULT = "DATA/WORK"; - + /** Setting key of the property that collects the names of all servlets that have been used so far. */ public static final String SERVER_SERVLETS_CALLED = "server.servlets.called"; - + /** Key of the setting controlling whether HTTP responses should be compressed with gzip when the user-agent accepts it (by including gzip in a 'Accept-Encoding' HTTP request header) */ public static final String SERVER_RESPONSE_COMPRESS_GZIP = "server.response.compress.gzip"; - + /** Default setting value controlling whether HTTP responses should be compressed */ public static final boolean SERVER_RESPONSE_COMPRESS_GZIP_DEFAULT = true; - - + + /** Key of the setting controlling the maximum number of simultaneously open outgoing HTTP connections in the general pool (net.yacy.cora.protocol.http.HTTPClient) */ public static final String HTTP_OUTGOING_POOL_GENERAL_MAX_TOTAL = "http.outgoing.pool.general.maxTotal"; - + /** Default setting value controlling the maximum number of simultaneously open outgoing HTTP connections in the general pool */ public static final int HTTP_OUTGOING_POOL_GENERAL_MAX_TOTAL_DEFAULT = 200; - + /** Key of the setting controlling the maximum number of simultaneously open outgoing HTTP connections in the remote Solr pool (net.yacy.cora.federate.solr.instance.RemoteInstance) */ public static final String HTTP_OUTGOING_POOL_REMOTE_SOLR_MAX_TOTAL = "http.outgoing.pool.remoteSolr.maxTotal"; - + /** Default setting value controlling the maximum number of simultaneously open outgoing HTTP connections in the remote Solr pool */ public static final int HTTP_OUTGOING_POOL_REMOTE_SOLR_MAX_TOTAL_DEFAULT = 100; - + /** Key of the setting controlling whether TLS Server Name Indication (SNI) extension is enabled on outgoing HTTP connections in the general http client (net.yacy.cora.protocol.http.HTTPClient) */ public static final String HTTP_OUTGOING_GENERAL_TLS_SNI_EXTENSION_ENABLED = "http.outgoing.general.tls.sniExtension.enabled"; - + /** Key of the setting controlling whether TLS Server Name Indication (SNI) extension is enabled on outgoing HTTP connections in the remote Solr http client (net.yacy.cora.federate.solr.instance.RemoteInstance) */ public static final String HTTP_OUTGOING_REMOTE_SOLR_TLS_SNI_EXTENSION_ENABLED = "http.outgoing.remoteSolr.tls.sniExtension.enabled"; - + /* @@ -525,43 +526,43 @@ public final class SwitchboardConstants { * under/overshot states in the system are supposed to be regulated to match the steady-state value * ATTENTION: be aware that using the autoregulate-option causes that the search index data is DELETED as soon as threshold-values are reached! */ - + /** Setting key to enable auto-regulation on disk free threshold values */ public static final String RESOURCE_DISK_FREE_AUTOREGULATE = "resource.disk.free.autoregulate"; - + /** Default disk free auto-regulation activation setting */ public static final boolean RESOURCE_DISK_FREE_AUTOREGULATE_DEFAULT = false; - + /** Setting key for the target steady-state of minimum disk space left */ public static final String RESOURCE_DISK_FREE_MIN_STEADYSTATE = "resource.disk.free.min.steadystate"; - + /** Default value for target steady-state of minimum disk space left */ public static final long RESOURCE_DISK_FREE_MIN_STEADYSTATE_DEFAULT = 2048L; - + /** Setting key for the undershot below the steady-state of minimum disk free as absolute size */ public static final String RESOURCE_DISK_FREE_MIN_UNDERSHOT = "resource.disk.free.min.undershot"; - + /** Default value for undershot below the steady-state of minimum disk free as absolute size */ public static final long RESOURCE_DISK_FREE_MIN_UNDERSHOT_DEFAULT = 1024L; - + /** Setting key to enable auto-regulation on disk used threshold values */ public static final String RESOURCE_DISK_USED_AUTOREGULATE = "resource.disk.used.autoregulate"; - + /** Default disk used auto-regulation activation setting */ public static final boolean RESOURCE_DISK_USED_AUTOREGULATE_DEFAULT = false; - + /** Setting key for the disk used maximum steady state value */ public static final String RESOURCE_DISK_USED_MAX_STEADYSTATE = "resource.disk.used.max.steadystate"; - + /** Default disk used maximum steady state value (in mebibyte)*/ public static final long RESOURCE_DISK_USED_MAX_STEADYSTATE_DEFAULT = 524288L; - + /** Setting key for the disk used hard upper limit value */ public static final String RESOURCE_DISK_USED_MAX_OVERSHOT = "resource.disk.used.max.overshot"; - + /** Default disk used hard upper limit value (in mebibyte) */ public static final long RESOURCE_DISK_USED_MAX_OVERSHOT_DEFAULT = 1048576L; - + public static final String MEMORY_ACCEPTDHT = "memory.acceptDHTabove"; // minimum memory to accept dht-in (MiB) public static final String INDEX_RECEIVE_AUTODISABLED = "memory.disabledDHT"; // set if DHT was disabled by ResourceObserver public static final String CRAWLJOB_LOCAL_AUTODISABLED = "memory.disabledLocalCrawler"; // set if local crawl was disabled by ResourceObserver @@ -584,11 +585,11 @@ public final class SwitchboardConstants { public static final String NETWORK_BOOTSTRAP_SEEDLIST_STUB = "network.unit.bootstrap.seedlist"; public static final String NETWORK_SEARCHVERIFY = "network.unit.inspection.searchverify"; - + /** Key of the setting controlling whether https should be preferred for in-protocol operations when available on remote peers. * A distinct general setting is available to control whether https sould be used for remote search queries : see {@link #REMOTESEARCH_HTTPS_PREFERRED} */ public static final String NETWORK_PROTOCOL_HTTPS_PREFERRED = "network.unit.protocol.https.preferred"; - + /** Default setting value controlling whether https should be preferred for in-protocol operations when available on remote peers */ public static final boolean NETWORK_PROTOCOL_HTTPS_PREFERRED_DEFAULT = false; @@ -623,66 +624,66 @@ public final class SwitchboardConstants { public static final String SEARCH_TARGET_SPECIAL_PATTERN = "search.target.special.pattern"; // ie 'own' addresses in topframe, 'other' in iframe public static final String SEARCH_VERIFY = "search.verify"; public static final String SEARCH_VERIFY_DELETE = "search.verify.delete"; - + /** * Key of the setting controlling whether content domain filtering is strict : * when false, results can be extended to documents including links to documents * of contentdom type, whithout being themselves of that type. */ public static final String SEARCH_STRICT_CONTENT_DOM = "search.strictContentDom"; - + /** Default setting value controlling whether content domain filtering is strict. */ public static final boolean SEARCH_STRICT_CONTENT_DOM_DEFAULT = false; - + /** Key of the setting controlling whether search results resorting by browser JavaScript is enabled */ public static final String SEARCH_JS_RESORT = "search.jsresort"; - + /** Default setting value controlling whether search results resorting by browser JavaScript is enabled */ public static final boolean SEARCH_JS_RESORT_DEFAULT = false; - + /** Key of the setting controlling whether the search public top navigation bar includes a login link/status */ public static final String SEARCH_PUBLIC_TOP_NAV_BAR_LOGIN = "search.publicTopNavBar.login"; - + /** Default setting value controlling whether the search public top navigation bar includes a login link/status */ public static final boolean SEARCH_PUBLIC_TOP_NAV_BAR_LOGIN_DEFAULT = true; /** Key of the setting controlling the max lines displayed in standard search navigators/facets */ public static final String SEARCH_NAVIGATION_MAXCOUNT = "search.navigation.maxcount"; - + /** Key of the setting controlling the max lines displayed in the dates navigator */ public static final String SEARCH_NAVIGATION_DATES_MAXCOUNT = "search.navigation.dates.maxcount"; - + /** Key of the setting controlling whether a noreferrer link type should be added to search result links */ public static final String SEARCH_RESULT_NOREFERRER = "search.result.noreferrer"; - + /** Default setting value controlling whether a noreferrer link type should be added to search result links */ public static final boolean SEARCH_RESULT_NOREFERRER_DEFAULT = false; - + /** Key of the setting controlling whether the ranking score value should be displayed for each search result in the HTML results page */ public static final String SEARCH_RESULT_SHOW_RANKING = "search.result.show.ranking"; - + /** Default setting value controlling whether the ranking score value should be displayed for each search result in the HTML results page */ public static final boolean SEARCH_RESULT_SHOW_RANKING_DEFAULT = false; - + /** Key of the setting controlling whether a tags/keywords list should be displayed for each search result in the HTML results page */ public static final String SEARCH_RESULT_SHOW_KEYWORDS = "search.result.show.keywords"; - + /** Default setting value controlling whether the ranking score value should be displayed for each search result in the HTML results page */ public static final boolean SEARCH_RESULT_SHOW_KEYWORDS_DEFAULT = false; - + /** Key of the setting controlling the maximum number of tags/keywords initially displayed for each search result in the HTML results page (the eventual remaining ones can then be expanded) */ public static final String SEARCH_RESULT_KEYWORDS_FISRT_MAX_COUNT = "search.result.keywords.firstMaxCount"; - + /** Default setting value controlling the maximum number of tags/keywords initially displayed for each search result in the HTML results page (the eventual remaining ones can then be expanded) */ public static final int SEARCH_RESULT_KEYWORDS_FISRT_MAX_COUNT_DEFAULT = 100; - + /** Key of the setting controlling whether the eventual website favicon should be fetched and displayed for each search result in the HTML results page */ public static final String SEARCH_RESULT_SHOW_FAVICON = "search.result.show.favicon"; - + /** Default setting value controlling whether the eventual website favicon should be fetched and displayed for each search result in the HTML results page */ public static final boolean SEARCH_RESULT_SHOW_FAVICON_DEFAULT = true; - - + + /** * ranking+evaluation @@ -699,7 +700,7 @@ public final class SwitchboardConstants { public static final String SEARCH_RANKING_SOLR_COLLECTION_FILTERQUERY_ = "search.ranking.solr.collection.filterquery.tmpa."; public static final String SEARCH_RANKING_SOLR_COLLECTION_BOOSTQUERY_ = "search.ranking.solr.collection.boostquery.tmpa."; public static final String SEARCH_RANKING_SOLR_COLLECTION_BOOSTFUNCTION_ = "search.ranking.solr.collection.boostfunction.tmpb."; - + /** * system tray */ @@ -707,7 +708,7 @@ public final class SwitchboardConstants { public static final String TRAY_ICON_FORCED = "tray.icon.force"; public static final String TRAY_ICON_LABEL = "tray.icon.label"; public static final String TRAY_MENU_ENABLED = "tray.menu.enabled"; - + /* * search heuristics */ @@ -715,7 +716,7 @@ public final class SwitchboardConstants { public static final String HEURISTIC_SEARCHRESULTS = "heuristic.searchresults"; public static final String HEURISTIC_SEARCHRESULTS_CRAWLGLOBAL = "heuristic.searchresults.crawlglobal"; public static final String HEURISTIC_OPENSEARCH = "heuristic.opensearch"; - + /* * automatic learning heuristic */ @@ -727,7 +728,7 @@ public final class SwitchboardConstants { * Skins */ public static final String SKINS_PATH_DEFAULT = "DATA/SKINS"; - + /* * decorations */ diff --git a/source/net/yacy/server/serverSwitch.java b/source/net/yacy/server/serverSwitch.java index 7a9e48cfb..073aec83c 100644 --- a/source/net/yacy/server/serverSwitch.java +++ b/source/net/yacy/server/serverSwitch.java @@ -53,7 +53,6 @@ import net.yacy.cora.util.ConcurrentLog; import net.yacy.http.YaCyHttpServer;
import net.yacy.kelondro.util.FileUtils;
import net.yacy.kelondro.workflow.BusyThread;
-import net.yacy.kelondro.workflow.WorkflowThread;
import net.yacy.peers.Seed;
import net.yacy.search.SwitchboardConstants;
@@ -94,14 +93,14 @@ public class serverSwitch { if (initFile.exists()) {
initProps = FileUtils.loadMap(initFile);
} else {
- initProps = new ConcurrentHashMap<String, String>();
+ initProps = new ConcurrentHashMap<>();
}
// load config's from last save
if (this.configFile.exists()) {
this.configProps = FileUtils.loadMap(this.configFile);
} else {
- this.configProps = new ConcurrentHashMap<String, String>();
+ this.configProps = new ConcurrentHashMap<>();
}
// overwrite configs with values from environment variables that start with "yacy_"
@@ -114,7 +113,7 @@ public class serverSwitch { });
// remove all values from config that do not appear in init
- this.configRemoved = new ConcurrentHashMap<String, String>();
+ this.configRemoved = new ConcurrentHashMap<>();
final Iterator<String> i = this.configProps.keySet().iterator();
String key;
while (i.hasNext()) {
@@ -150,19 +149,19 @@ public class serverSwitch { // save result; this may initially create a config file after
// initialization
- saveConfig();
+ this.saveConfig();
// init thread control
- this.workerThreads = new TreeMap<String, BusyThread>();
+ this.workerThreads = new TreeMap<>();
// init busy state control
// this.serverJobs = 0;
// init server tracking
serverAccessTracker.init(
- getConfigLong("server.maxTrackingTime", 60 * 60 * 1000),
- (int) getConfigLong("server.maxTrackingCount", 1000),
- (int) getConfigLong("server.maxTrackingHostCount", 100));
+ this.getConfigLong("server.maxTrackingTime", 60 * 60 * 1000),
+ (int) this.getConfigLong("server.maxTrackingCount", 1000),
+ (int) this.getConfigLong("server.maxTrackingHostCount", 100));
}
/**
@@ -174,7 +173,7 @@ public class serverSwitch { */
public String myPublicIP() {
// if a static IP was configured, we have to return it here ...
- final String staticIP = getConfig(SwitchboardConstants.SERVER_STATICIP, "");
+ final String staticIP = this.getConfig(SwitchboardConstants.SERVER_STATICIP, "");
if (staticIP.length() > 0)
return staticIP;
@@ -193,7 +192,7 @@ public class serverSwitch { */
public Set<String> myPublicIPs() {
// if a static IP was configured, we have to return it here ...
- final String staticIP = getConfig(SwitchboardConstants.SERVER_STATICIP, "");
+ final String staticIP = this.getConfig(SwitchboardConstants.SERVER_STATICIP, "");
if (staticIP.length() > 0) {
final HashSet<String> h = new HashSet<>();
h.add(staticIP);
@@ -235,7 +234,7 @@ public class serverSwitch { // TODO: add way of setting and retrieving port for manual NAT
- return getConfigInt(key, dflt);
+ return this.getConfigInt(key, dflt);
}
/**
@@ -248,7 +247,11 @@ public class serverSwitch { * @see #getPublicPort(String, int)
*/
public int getLocalPort() {
- return getConfigInt(SwitchboardConstants.SERVER_PORT, 8090);
+ return this.getConfigInt(SwitchboardConstants.SERVER_PORT, 8090);
+ }
+
+ public String getLocalHost() {
+ return this.getConfig(SwitchboardConstants.SERVER_HOST, "0.0.0.0");
}
// a logger for this switchboard
@@ -271,45 +274,45 @@ public class serverSwitch { Map.Entry<String, String> entry;
while (i.hasNext()) {
entry = i.next();
- setConfig(entry.getKey(), entry.getValue());
+ this.setConfig(entry.getKey(), entry.getValue());
}
}
public void setConfig(final String key, final boolean value) {
- setConfig(key, (value) ? "true" : "false");
+ this.setConfig(key, (value) ? "true" : "false");
}
public void setConfig(final String key, final long value) {
- setConfig(key, Long.toString(value));
+ this.setConfig(key, Long.toString(value));
}
public void setConfig(final String key, final float value) {
- setConfig(key, Float.toString(value));
+ this.setConfig(key, Float.toString(value));
}
public void setConfig(final String key, final double value) {
- setConfig(key, Double.toString(value));
+ this.setConfig(key, Double.toString(value));
}
public void setConfig(final String key, final String value) {
// set the value
final String oldValue = this.configProps.put(key, value);
if (oldValue == null || !value.equals(oldValue)) {
- saveConfig();
+ this.saveConfig();
}
}
public void setConfig(final String key, final String[] value) {
final StringBuilder sb = new StringBuilder();
if (value != null) for (final String s: value) sb.append(',').append(s);
- setConfig(key, sb.length() > 0 ? sb.substring(1) : "");
+ this.setConfig(key, sb.length() > 0 ? sb.substring(1) : "");
}
public void setConfig(final String key, final Set<String> value) {
final String[] a = new String[value.size()];
int c = 0;
for (final String s: value) a[c++] = s;
- setConfig(key, a);
+ this.setConfig(key, a);
}
public void removeConfig(final String key) {
@@ -349,7 +352,7 @@ public class serverSwitch { */
public long getConfigLong(final String key, final long dflt) {
try {
- return Long.parseLong(getConfig(key, Long.toString(dflt)));
+ return Long.parseLong(this.getConfig(key, Long.toString(dflt)));
} catch (final NumberFormatException e) {
return dflt;
}
@@ -367,7 +370,7 @@ public class serverSwitch { */
public float getConfigFloat(final String key, final float dflt) {
try {
- return Float.parseFloat(getConfig(key, Float.toString(dflt)));
+ return Float.parseFloat(this.getConfig(key, Float.toString(dflt)));
} catch (final NumberFormatException e) {
return dflt;
}
@@ -409,7 +412,7 @@ public class serverSwitch { public int getConfigInt(final String key, final int dflt) {
try {
- return Integer.parseInt(getConfig(key, Integer.toString(dflt)));
+ return Integer.parseInt(this.getConfig(key, Integer.toString(dflt)));
} catch (final NumberFormatException e) {
return dflt;
@@ -427,7 +430,7 @@ public class serverSwitch { * @return value if the parameter or default value
*/
public boolean getConfigBool(final String key, final boolean dflt) {
- return Boolean.parseBoolean(getConfig(key, Boolean.toString(dflt)));
+ return Boolean.parseBoolean(this.getConfig(key, Boolean.toString(dflt)));
}
/**
@@ -447,7 +450,7 @@ public class serverSwitch { */
public Set<String> getConfigSet(final String key) {
final Set<String> h = new LinkedHashSet<>();
- for (String s: getConfigArray(key, "")) {s = s.trim(); if (s.length() > 0) h.add(s.trim());}
+ for (String s: this.getConfigArray(key, "")) {s = s.trim(); if (s.length() > 0) h.add(s.trim());}
return h;
}
@@ -465,7 +468,7 @@ public class serverSwitch { * relative path setting.
*/
public File getDataPath(final String key, final String dflt) {
- return getFileByPath(key, dflt, this.dataPath);
+ return this.getFileByPath(key, dflt, this.dataPath);
}
/**
@@ -476,11 +479,11 @@ public class serverSwitch { * @return
*/
public File getAppPath(final String key, final String dflt) {
- return getFileByPath(key, dflt, this.appPath);
+ return this.getFileByPath(key, dflt, this.appPath);
}
private File getFileByPath(final String key, final String dflt, final File prefix) {
- final String path = getConfig(key, dflt).replace('\\', '/');
+ final String path = this.getConfig(key, dflt).replace('\\', '/');
final File f = new File(path);
return (f.isAbsolute() ? new File(f.getAbsolutePath()) : new File(
prefix, path));
@@ -494,8 +497,7 @@ public class serverSwitch { * write the changes to permanent storage (File)
*/
private void saveConfig() {
- final ConcurrentMap<String, String> configPropsCopy = new ConcurrentHashMap<String, String>();
- configPropsCopy.putAll(this.configProps); // avoid concurrency problems
+ final ConcurrentMap<String, String> configPropsCopy = new ConcurrentHashMap<>(this.configProps);
FileUtils.saveMap(this.configFile, configPropsCopy, this.configComment);
}
@@ -530,17 +532,17 @@ public class serverSwitch { final String threadShortDescription,
final String threadLongDescription, final String threadMonitorURL,
final BusyThread newThread, final long startupDelay) {
- deployThread(
+ this.deployThread(
threadName,
threadShortDescription,
threadLongDescription,
threadMonitorURL,
newThread,
startupDelay,
- Long.parseLong(getConfig(threadName + "_idlesleep", "1000")),
- Long.parseLong(getConfig(threadName + "_busysleep", "100")),
- Long.parseLong(getConfig(threadName + "_memprereq", "1048576")),
- Double.parseDouble(getConfig(threadName + "_loadprereq", "9.0")));
+ Long.parseLong(this.getConfig(threadName + "_idlesleep", "1000")),
+ Long.parseLong(this.getConfig(threadName + "_busysleep", "100")),
+ Long.parseLong(this.getConfig(threadName + "_memprereq", "1048576")),
+ Double.parseDouble(this.getConfig(threadName + "_loadprereq", "9.0")));
}
public void deployThread(final String threadName,
@@ -557,33 +559,33 @@ public class serverSwitch { newThread.setStartupSleep(startupDelay);
long x;
try {
- x = Long.parseLong(getConfig(threadName + "_idlesleep", "novalue"));
+ x = Long.parseLong(this.getConfig(threadName + "_idlesleep", "novalue"));
newThread.setIdleSleep(x);
} catch (final NumberFormatException e) {
newThread.setIdleSleep(initialIdleSleep);
- setConfig(threadName + "_idlesleep", initialIdleSleep);
+ this.setConfig(threadName + "_idlesleep", initialIdleSleep);
}
try {
- x = Long.parseLong(getConfig(threadName + "_busysleep", "novalue"));
+ x = Long.parseLong(this.getConfig(threadName + "_busysleep", "novalue"));
newThread.setBusySleep(x);
} catch (final NumberFormatException e) {
newThread.setBusySleep(initialBusySleep);
- setConfig(threadName + "_busysleep", initialBusySleep);
+ this.setConfig(threadName + "_busysleep", initialBusySleep);
}
try {
- x = Long.parseLong(getConfig(threadName + "_memprereq", "novalue"));
+ x = Long.parseLong(this.getConfig(threadName + "_memprereq", "novalue"));
newThread.setMemPreReqisite(x);
} catch (final NumberFormatException e) {
newThread.setMemPreReqisite(initialMemoryPreRequisite);
- setConfig(threadName + "_memprereq", initialMemoryPreRequisite);
+ this.setConfig(threadName + "_memprereq", initialMemoryPreRequisite);
}
try {
- final double load = Double.parseDouble(getConfig(threadName
+ final double load = Double.parseDouble(this.getConfig(threadName
+ "_loadprereq", "novalue"));
newThread.setLoadPreReqisite(load);
} catch (final NumberFormatException e) {
newThread.setLoadPreReqisite(initialLoadPreRequisite);
- setConfig(threadName + "_loadprereq",
+ this.setConfig(threadName + "_loadprereq",
(float) initialLoadPreRequisite);
}
newThread.setDescription(threadShortDescription, threadLongDescription,
@@ -604,13 +606,13 @@ public class serverSwitch { final long memprereqBytes, final double loadprereq) {
final BusyThread thread = this.workerThreads.get(threadName);
if (thread != null) {
- setConfig(threadName + "_idlesleep",
+ this.setConfig(threadName + "_idlesleep",
thread.setIdleSleep(idleMillis));
- setConfig(threadName + "_busysleep",
+ this.setConfig(threadName + "_busysleep",
thread.setBusySleep(busyMillis));
- setConfig(threadName + "_memprereq", memprereqBytes);
+ this.setConfig(threadName + "_memprereq", memprereqBytes);
thread.setMemPreReqisite(memprereqBytes);
- setConfig(threadName + "_loadprereq", (float) loadprereq);
+ this.setConfig(threadName + "_loadprereq", (float) loadprereq);
thread.setLoadPreReqisite(loadprereq);
}
}
@@ -618,7 +620,7 @@ public class serverSwitch { public synchronized void terminateThread(final String threadName,
final boolean waitFor) {
if (this.workerThreads.containsKey(threadName)) {
- ((WorkflowThread) this.workerThreads.get(threadName))
+ this.workerThreads.get(threadName)
.terminate(waitFor);
this.workerThreads.remove(threadName);
}
@@ -634,13 +636,13 @@ public class serverSwitch { public synchronized void terminateAllThreads(final boolean waitFor) {
Iterator<String> e = this.workerThreads.keySet().iterator();
while (e.hasNext()) {
- ((WorkflowThread) this.workerThreads.get(e.next()))
+ this.workerThreads.get(e.next())
.terminate(false);
}
if (waitFor) {
e = this.workerThreads.keySet().iterator();
while (e.hasNext()) {
- ((WorkflowThread) this.workerThreads.get(e.next()))
+ this.workerThreads.get(e.next())
.terminate(true);
e.remove();
}
@@ -691,8 +693,8 @@ public class serverSwitch { reqHeader.put(HeaderFramework.USER_AGENT, ClientIdentification.yacyInternetCrawlerAgent.userAgent);
client.setHeader(reqHeader.entrySet());
final byte[] data = client.GETbytes(uri,
- getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin"),
- getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""), false);
+ this.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin"),
+ this.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""), false);
if (data == null || data.length == 0) {
continue;
}
diff --git a/source/net/yacy/yacy.java b/source/net/yacy/yacy.java index a7626bac3..48c94fe26 100644 --- a/source/net/yacy/yacy.java +++ b/source/net/yacy/yacy.java @@ -292,10 +292,11 @@ public final class yacy { // start main threads
final int port = sb.getLocalPort();
+ final String host = sb.getLocalHost();
try {
// start http server
YaCyHttpServer httpServer;
- httpServer = new YaCyHttpServer(port, "0.0.0.0");
+ httpServer = new YaCyHttpServer(port, host);
httpServer.startupServer();
sb.setHttpServer(httpServer);
// TODO: this has no effect on Jetty (but needed to reflect configured value and limit is still used)
|
