Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

Merge branch 'master' of ssh://gitorious.org/yacy/rc1 into jetty

Michael Peter Christen65f56b1fd464
diff --cc .classpath
index 3803c1c8a,e6ba6ace3..730b621c5
--- a/.classpath
+++ b/.classpath
@@@ -1,55 -1,72 +1,80 @@@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry excluding="env/|htdocsdefault/|proxymsg/|yacy/|env/|yacy/user/|yacy/user/|yacy/ui/|processing/domaingraph/applet/|processing/domaingraph/|api/|api/bookmarks/posts/|api/bookmarks/|api/util/|api/bookmarks/xbel/|api/bookmarks/tags/|api/ymarks/" kind="src" path="htroot"/>
- <classpathentry kind="src" path="test"/>
- <classpathentry excluding="user/|user/|ui/" kind="src" path="htroot/yacy"/>
- <classpathentry kind="src" path="htroot/env"/>
-- <classpathentry kind="src" path="source"/>
- <classpathentry kind="src" path="htroot/yacy/ui"/>
- <classpathentry excluding="bookmarks/posts/|bookmarks/|util/|bookmarks/xbel/|bookmarks/tags/|ymarks/" kind="src" path="htroot/api"/>
- <classpathentry kind="src" path="htroot/api/bookmarks/posts"/>
- <classpathentry excluding="posts/|xbel/|tags/" kind="src" path="htroot/api/bookmarks"/>
- <classpathentry kind="src" path="htroot/api/util"/>
- <classpathentry kind="src" path="htroot/api/bookmarks/xbel"/>
- <classpathentry kind="src" path="htroot/api/bookmarks/tags"/>
- <classpathentry kind="src" path="htroot/api/ymarks"/>
+ <classpathentry excluding="api/|env/|processing/domaingraph/applet/|yacy/|api/bookmarks/|api/ymarks/|api/bookmarks/posts/|api/bookmarks/tags/|api/bookmarks/xbel/" kind="src" path="htroot"/>
+ <classpathentry excluding="bookmarks/|ymarks/|bookmarks/posts/|bookmarks/tags/|bookmarks/xbel/" kind="src" path="htroot/api"/>
- <classpathentry kind="src" path="htroot/env"/>
- <classpathentry kind="src" path="htroot/yacy"/>
+ <classpathentry excluding="posts/|tags/|xbel/" kind="src" path="htroot/api/bookmarks"/>
- <classpathentry kind="src" path="htroot/api/ymarks"/>
- <classpathentry kind="src" path="htroot/api/bookmarks/posts"/>
- <classpathentry kind="src" path="htroot/api/bookmarks/tags"/>
- <classpathentry kind="src" path="htroot/api/bookmarks/xbel"/>
++ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-- <classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/>
- <classpathentry kind="lib" path="lib/commons-io-1.4.jar"/>
- <classpathentry kind="lib" path="lib/servlet-api.jar"/>
- <classpathentry kind="lib" path="lib/xerces.jar"/>
- <classpathentry kind="lib" path="lib/bzip2.jar"/>
<classpathentry kind="lib" path="lib/J7Zip-modified.jar"/>
-- <classpathentry kind="lib" path="lib/webcat-0.1-swf.jar"/>
<classpathentry kind="lib" path="lib/activation.jar"/>
-- <classpathentry kind="lib" path="lib/commons-jxpath-1.3.jar"/>
- <classpathentry kind="lib" path="lib/poi-3.6-20091214.jar"/>
- <classpathentry kind="lib" path="lib/poi-3.6-20091214.jar" sourcepath="/Users/admin/.m2/repository/org/apache/poi/poi/3.6/poi-3.6-sources.jar"/>
-- <classpathentry kind="lib" path="lib/poi-scratchpad-3.6-20091214.jar"/>
++ <classpathentry kind="lib" path="lib/apache-mime4j-0.6.jar"/>
++ <classpathentry kind="lib" path="lib/apache-solr-core-3.6.0.jar" sourcepath="/Volumes/Raptor/Data/workspace1/apache-solr-3.6.0/src/java"/>
++ <classpathentry kind="lib" path="lib/apache-solr-solrj-3.6.0.jar" sourcepath="/Volumes/Raptor/Data/workspace1/apache-solr-3.6.0/src/java"/>
++ <classpathentry kind="lib" path="lib/arq-2.8.7.jar"/>
<classpathentry kind="lib" path="lib/bcmail-jdk15-145.jar"/>
<classpathentry kind="lib" path="lib/bcprov-jdk15-145.jar"/>
-- <classpathentry kind="lib" path="lib/jsch-0.1.42.jar"/>
-- <classpathentry kind="lib" path="lib/jakarta-oro-2.0.8.jar"/>
- <classpathentry kind="lib" path="lib/commons-codec-1.4.jar"/>
-- <classpathentry kind="lib" path="lib/mysql-connector-java-5.1.12-bin.jar"/>
- <classpathentry kind="lib" path="lib/jcifs-1.3.14.jar"/>
- <classpathentry kind="lib" path="lib/jcifs-1.3.15.jar"/>
-- <classpathentry kind="lib" path="lib/metadata-extractor-2.4.0-beta-1.jar"/>
- <classpathentry kind="lib" path="lib/httpclient-4.1.jar"/>
- <classpathentry kind="lib" path="lib/httpcore-4.1.jar"/>
- <classpathentry kind="lib" path="lib/httpmime-4.1.jar"/>
-- <classpathentry kind="lib" path="lib/apache-mime4j-0.6.jar"/>
- <classpathentry kind="lib" path="lib/fontbox-1.2.1.jar"/>
- <classpathentry kind="lib" path="lib/pdfbox-1.2.1.jar"/>
- <classpathentry kind="lib" path="lib/commons-fileupload-1.2.2.jar"/>
- <classpathentry kind="lib" path="lib/log4j-1.2.16.jar"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
++ <classpathentry kind="lib" path="lib/commons-codec-1.6.jar"/>
++ <classpathentry kind="lib" path="lib/commons-compress-1.4.1.jar"/>
+ <classpathentry kind="lib" path="lib/commons-fileupload-1.2.2.jar" sourcepath="/Users/admin/.m2/repository/commons-fileupload/commons-fileupload/1.2.2/commons-fileupload-1.2.2-sources.jar"/>
- <classpathentry kind="lib" path="lib/log4j-1.2.16.jar"/>
- <classpathentry kind="lib" path="lib/json-simple-1.1.jar"/>
- <classpathentry kind="lib" path="lib/xercesImpl.jar"/>
- <classpathentry kind="lib" path="lib/xml-apis.jar"/>
- <classpathentry kind="lib" path="lib/slf4j-api-1.6.1.jar"/>
- <classpathentry kind="lib" path="lib/slf4j-jdk14-1.6.1.jar"/>
++ <classpathentry kind="lib" path="lib/commons-httpclient-3.1.jar"/>
++ <classpathentry kind="lib" path="lib/commons-io-2.1.jar"/>
++ <classpathentry kind="lib" path="lib/commons-jxpath-1.3.jar"/>
++ <classpathentry kind="lib" path="lib/commons-lang-2.6.jar"/>
++ <classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/>
++ <classpathentry kind="lib" path="lib/fontbox-1.7.0.jar"/>
+ <classpathentry kind="lib" path="lib/geronimo-stax-api_1.0_spec-1.0.1.jar"/>
- <classpathentry kind="lib" path="lib/jcl-over-slf4j-1.6.1.jar"/>
- <classpathentry kind="lib" path="lib/wstx-asl-3.2.7.jar"/>
- <classpathentry kind="lib" path="lib/commons-codec-1.6.jar"/>
- <classpathentry kind="lib" path="lib/httpcore-4.2.jar"/>
++ <classpathentry kind="lib" path="lib/guava-r05.jar"/>
++ <classpathentry kind="lib" path="lib/htmllexer.jar"/>
++ <classpathentry kind="lib" path="lib/htmlparser.jar"/>
+ <classpathentry kind="lib" path="lib/httpclient-4.2.jar"/>
++ <classpathentry kind="lib" path="lib/httpcore-4.2.jar"/>
+ <classpathentry kind="lib" path="lib/httpmime-4.2.jar"/>
- <classpathentry kind="lib" path="lib/commons-io-2.1.jar"/>
- <classpathentry kind="lib" path="lib/commons-compress-1.4.1.jar"/>
- <classpathentry kind="lib" path="lib/guava-r05.jar"/>
+ <classpathentry kind="lib" path="lib/icu4j-core.jar"/>
++ <classpathentry kind="lib" path="lib/iri-0.8.jar"/>
++ <classpathentry kind="lib" path="lib/jakarta-oro-2.0.8.jar"/>
++ <classpathentry kind="lib" path="lib/jcifs-1.3.15.jar"/>
++ <classpathentry kind="lib" path="lib/jcl-over-slf4j-1.6.1.jar"/>
++ <classpathentry kind="lib" path="lib/jempbox-1.7.0.jar"/>
++ <classpathentry kind="lib" path="lib/jena-2.6.4.jar" sourcepath="/Users/admin/.m2/repository/com/hp/hpl/jena/jena/2.6.4/jena-2.6.4-sources.jar"/>
++ <classpathentry kind="lib" path="lib/jetty-6.1.26-patched-JETTY-1340.jar"/>
++ <classpathentry kind="lib" path="lib/jetty-continuation-7.3.0.v20110203.jar"/>
+ <classpathentry kind="lib" path="lib/jetty-http-7.3.0.v20110203.jar"/>
- <classpathentry kind="lib" path="lib/jetty-server-7.3.0.v20110203.jar"/>
- <classpathentry kind="lib" path="lib/jetty-util-7.3.0.v20110203.jar"/>
+ <classpathentry kind="lib" path="lib/jetty-io-7.3.0.v20110203.jar"/>
- <classpathentry kind="lib" path="lib/jetty-continuation-7.3.0.v20110203.jar"/>
+ <classpathentry kind="lib" path="lib/jetty-security-7.3.0.v20110203.jar"/>
++ <classpathentry kind="lib" path="lib/jetty-server-7.3.0.v20110203.jar"/>
+ <classpathentry kind="lib" path="lib/jetty-servlet-7.3.0.v20110203.jar"/>
+ <classpathentry kind="lib" path="lib/jetty-servlets-7.3.0.v20110203.jar"/>
++ <classpathentry kind="lib" path="lib/jetty-util-6.1.26-patched-JETTY-1340.jar"/>
++ <classpathentry kind="lib" path="lib/jetty-util-7.3.0.v20110203.jar"/>
++ <classpathentry kind="lib" path="lib/jsch-0.1.42.jar"/>
++ <classpathentry kind="lib" path="lib/json-simple-1.1.jar"/>
++ <classpathentry kind="lib" path="lib/log4j-1.2.16.jar"/>
+ <classpathentry kind="lib" path="lib/log4j-over-slf4j-1.6.1.jar"/>
- <classpathentry kind="lib" path="lib/commons-lang-2.6.jar"/>
++ <classpathentry kind="lib" path="lib/lucene-analyzers-3.6.0.jar"/>
+ <classpathentry kind="lib" path="lib/lucene-core-3.6.0.jar"/>
- <classpathentry kind="lib" path="lib/apache-solr-solrj-3.6.0.jar" sourcepath="/Volumes/Raptor/Data/workspace1/apache-solr-3.6.0/src/java"/>
++ <classpathentry kind="lib" path="lib/lucene-highlighter-3.6.0.jar"/>
+ <classpathentry kind="lib" path="lib/lucene-phonetic-3.6.0.jar"/>
+ <classpathentry kind="lib" path="lib/lucene-spatial-3.6.0.jar"/>
+ <classpathentry kind="lib" path="lib/lucene-spellchecker-3.6.0.jar"/>
- <classpathentry kind="lib" path="lib/commons-httpclient-3.1.jar"/>
- <classpathentry kind="lib" path="lib/lucene-highlighter-3.6.0.jar"/>
- <classpathentry kind="lib" path="lib/lucene-analyzers-3.6.0.jar"/>
- <classpathentry kind="lib" path="lib/servlet-api-2.5-20081211.jar"/>
- <classpathentry kind="lib" path="lib/jetty-6.1.26-patched-JETTY-1340.jar"/>
- <classpathentry kind="lib" path="lib/jetty-util-6.1.26-patched-JETTY-1340.jar"/>
- <classpathentry kind="lib" path="lib/fontbox-1.7.0.jar"/>
++ <classpathentry kind="lib" path="lib/metadata-extractor-2.4.0-beta-1.jar"/>
++ <classpathentry kind="lib" path="lib/mysql-connector-java-5.1.12-bin.jar"/>
+ <classpathentry kind="lib" path="lib/pdfbox-1.7.0.jar"/>
- <classpathentry kind="lib" path="lib/jempbox-1.7.0.jar"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
- <classpathentry kind="lib" path="lib/icu4j-core.jar"/>
- <classpathentry kind="lib" path="lib/htmllexer.jar"/>
- <classpathentry kind="lib" path="lib/htmlparser.jar"/>
- <classpathentry kind="lib" path="lib/jena-2.6.4.jar" sourcepath="/Users/admin/.m2/repository/com/hp/hpl/jena/jena/2.6.4/jena-2.6.4-sources.jar"/>
++ <classpathentry kind="lib" path="lib/poi-3.6-20091214.jar" sourcepath="/Users/admin/.m2/repository/org/apache/poi/poi/3.6/poi-3.6-sources.jar"/>
++ <classpathentry kind="lib" path="lib/poi-scratchpad-3.6-20091214.jar"/>
+ <classpathentry kind="lib" path="lib/sax-2.0.1.jar"/>
- <classpathentry kind="lib" path="lib/arq-2.8.7.jar"/>
- <classpathentry kind="lib" path="lib/iri-0.8.jar"/>
- <classpathentry kind="lib" path="lib/apache-solr-core-3.6.0.jar" sourcepath="/Volumes/Raptor/Data/workspace1/apache-solr-3.6.0/src/java"/>
++ <classpathentry kind="lib" path="lib/servlet-api-2.5-20081211.jar"/>
++ <classpathentry kind="lib" path="lib/slf4j-api-1.6.1.jar"/>
++ <classpathentry kind="lib" path="lib/slf4j-jdk14-1.6.1.jar"/>
++ <classpathentry kind="lib" path="lib/webcat-0.1-swf.jar"/>
++ <classpathentry kind="lib" path="lib/wstx-asl-3.2.7.jar"/>
++ <classpathentry kind="lib" path="lib/xercesImpl.jar"/>
++ <classpathentry kind="lib" path="lib/xml-apis.jar"/>
<classpathentry kind="output" path="gen"/>
++ <classpathentry kind="src" path="htroot/api/bookmarks/posts"/>
++ <classpathentry kind="src" path="htroot/api/bookmarks/tags"/>
++ <classpathentry kind="src" path="htroot/api/bookmarks/xbel"/>
++ <classpathentry kind="src" path="htroot/api/ymarks"/>
++ <classpathentry kind="src" path="htroot/env"/>
++ <classpathentry kind="src" path="htroot/yacy"/>
++ <classpathentry kind="src" path="source"/>
</classpath>
diff --cc build.xml
index e94db8deb,12bdba82e..794d50f63
--- a/build.xml
+++ b/build.xml
@@@ -179,44 -156,64 +156,73 @@@
<path id="project.class.path">
<pathelement location="${build}" />
<pathelement location="${htroot}" />
- <pathelement location="${lib}/J7Zip-modified.jar" />
++ <pathelement location="${lib}/jetty-http-7.3.0.v20110203.jar" />
++ <pathelement location="${lib}/jetty-io-7.3.0.v20110203.jar" />
++ <pathelement location="${lib}/jetty-security-7.3.0.v20110203.jar" />
++ <pathelement location="${lib}/jetty-server-7.3.0.v20110203.jar" />
++ <pathelement location="${lib}/jetty-servlet-7.3.0.v20110203.jar" />
++ <pathelement location="${lib}/jetty-servlets-7.3.0.v20110203.jar" />
++ <pathelement location="${lib}/jetty-util-7.3.0.v20110203.jar" />
<pathelement location="${lib}/activation.jar" />
-- <pathelement location="${lib}/apache-mime4j-0.6.jar" />
- <pathelement location="${lib}/apache-solr-core-3.6.0.jar" />
- <pathelement location="${lib}/apache-solr-solrj-3.6.0.jar" />
- <pathelement location="${lib}/arq-2.8.7.jar" />
<pathelement location="${lib}/bcmail-jdk15-145.jar" />
<pathelement location="${lib}/bcprov-jdk15-145.jar" />
- <pathelement location="${lib}/bzip2.jar" />
- <pathelement location="${lib}/commons-codec-1.4.jar" />
+ <pathelement location="${lib}/commons-codec-1.6.jar" />
+ <pathelement location="${lib}/commons-compress-1.4.1.jar" />
<pathelement location="${lib}/commons-fileupload-1.2.2.jar" />
- <pathelement location="${lib}/commons-io-1.4.jar" />
+ <pathelement location="${lib}/commons-httpclient-3.1.jar" />
+ <pathelement location="${lib}/commons-io-2.1.jar" />
<pathelement location="${lib}/commons-jxpath-1.3.jar" />
+ <pathelement location="${lib}/commons-lang-2.6.jar" />
<pathelement location="${lib}/commons-logging-1.1.1.jar" />
- <pathelement location="${lib}/fontbox-1.2.1.jar" />
- <pathelement location="${lib}/httpclient-4.1.jar" />
- <pathelement location="${lib}/httpcore-4.1.jar" />
- <pathelement location="${lib}/httpmime-4.1.jar" />
- <pathelement location="${lib}/icu4j-core.jar" />
- <pathelement location="${lib}/J7Zip-modified.jar" />
- <pathelement location="${lib}/jakarta-oro-2.0.8.jar" />
- <pathelement location="${lib}/jetty-continuation-7.3.0.v20110203.jar" />
- <pathelement location="${lib}/jetty-server-7.3.0.v20110203.jar" />
- <pathelement location="${lib}/jetty-servlet-7.3.0.v20110203.jar" />
- <pathelement location="${lib}/jetty-servlets-7.3.0.v20110203.jar" />
- <pathelement location="${lib}/jetty-http-7.3.0.v20110203.jar" />
- <pathelement location="${lib}/jetty-util-7.3.0.v20110203.jar" />
- <pathelement location="${lib}/jetty-io-7.3.0.v20110203.jar" />
- <pathelement location="${lib}/jetty-security-7.3.0.v20110203.jar" />
+ <pathelement location="${lib}/fontbox-1.7.0.jar" />
- <pathelement location="${lib}/geronimo-stax-api_1.0_spec-1.0.1.jar" />
- <pathelement location="${lib}/guava-r05.jar" />
- <pathelement location="${lib}/htmllexer.jar" />
- <pathelement location="${lib}/htmlparser.jar" />
- <pathelement location="${lib}/httpclient-4.2.jar" />
- <pathelement location="${lib}/httpcore-4.2.jar" />
- <pathelement location="${lib}/httpmime-4.2.jar" />
- <pathelement location="${lib}/icu4j-core.jar" />
- <pathelement location="${lib}/iri-0.8.jar" />
- <pathelement location="${lib}/jakarta-oro-2.0.8.jar" />
+ <pathelement location="${lib}/jcifs-1.3.14.jar" />
+ <pathelement location="${lib}/jcifs-1.3.15.jar" />
+ <pathelement location="${lib}/jcl-over-slf4j-1.6.1.jar" />
+ <pathelement location="${lib}/jempbox-1.7.0" />
+ <pathelement location="${lib}/jena-2.6.4.jar" />
+ <pathelement location="${lib}/jetty-6.1.26-patched-JETTY-1340.jar" />
+ <pathelement location="${lib}/jetty-util-6.1.26-patched-JETTY-1340.jar" />
<pathelement location="${lib}/jsch-0.1.42.jar" />
+ <pathelement location="${lib}/json-simple-1.1.jar" />
<pathelement location="${lib}/log4j-1.2.16.jar" />
+ <pathelement location="${lib}/log4j-over-slf4j-1.6.1.jar" />
+ <pathelement location="${lib}/lucene-analyzers-3.6.0.jar" />
+ <pathelement location="${lib}/lucene-core-3.6.0.jar" />
+ <pathelement location="${lib}/lucene-highlighter-3.6.0.jar" />
+ <pathelement location="${lib}/lucene-phonetic-3.6.0.jar" />
+ <pathelement location="${lib}/lucene-spatial-3.6.0.jar" />
+ <pathelement location="${lib}/lucene-spellchecker-3.6.0.jar" />
<pathelement location="${lib}/metadata-extractor-2.4.0-beta-1.jar" />
<pathelement location="${lib}/mysql-connector-java-5.1.12-bin.jar" />
- <pathelement location="${lib}/pdfbox-1.2.1.jar" />
- <pathelement location="${lib}/pdfbox-1.7.0.jar" />
<pathelement location="${lib}/poi-3.6-20091214.jar" />
<pathelement location="${lib}/poi-scratchpad-3.6-20091214.jar" />
- <pathelement location="${lib}/servlet-api.jar" />
+ <pathelement location="${lib}/sax-2.0.1.jar" />
- <pathelement location="${lib}/servlet-api-2.5-20081211.jar" />
- <pathelement location="${lib}/slf4j-api-1.6.1.jar" />
- <pathelement location="${lib}/slf4j-jdk14-1.6.1.jar" />
<pathelement location="${lib}/webcat-0.1-swf.jar" />
- <pathelement location="${lib}/xerces.jar" />
+ <pathelement location="${lib}/wstx-asl-3.2.7.jar" />
+ <pathelement location="${lib}/xercesImpl.jar" />
+ <pathelement location="${lib}/xml-apis.jar" />
++ <pathelement location="${lib}/J7Zip-modified.jar" />
++ <pathelement location="${lib}/apache-mime4j-0.6.jar" />
++ <pathelement location="${lib}/apache-solr-core-3.6.0.jar" />
++ <pathelement location="${lib}/apache-solr-solrj-3.6.0.jar" />
++ <pathelement location="${lib}/arq-2.8.7.jar" />
++ <pathelement location="${lib}/geronimo-stax-api_1.0_spec-1.0.1.jar" />
++ <pathelement location="${lib}/guava-r05.jar" />
++ <pathelement location="${lib}/htmllexer.jar" />
++ <pathelement location="${lib}/htmlparser.jar" />
++ <pathelement location="${lib}/httpclient-4.2.jar" />
++ <pathelement location="${lib}/httpcore-4.2.jar" />
++ <pathelement location="${lib}/httpmime-4.2.jar" />
++ <pathelement location="${lib}/icu4j-core.jar" />
++ <pathelement location="${lib}/iri-0.8.jar" />
++ <pathelement location="${lib}/jakarta-oro-2.0.8.jar" />
++ <pathelement location="${lib}/jetty-continuation-7.3.0.v20110203.jar" />
++ <pathelement location="${lib}/pdfbox-1.7.0.jar" />
++ <pathelement location="${lib}/servlet-api-2.5-20081211.jar" />
++ <pathelement location="${lib}/slf4j-api-1.6.1.jar" />
++ <pathelement location="${lib}/slf4j-jdk14-1.6.1.jar" />
</path>
-
+
<target name="compile-core" depends="init" description="compile YaCy core">
<!-- compile yacyBuildProperties.java -->
diff --cc htroot/Status.java
index bfa1432af,0f599d57a..db5c9d1b0
--- a/htroot/Status.java
+++ b/htroot/Status.java
@@@ -309,23 -325,31 +325,32 @@@ public class Statu
// connection information
final serverCore httpd = (serverCore) sb.getThread("10_httpd");
- prop.putNum("connectionsActive", httpd.getJobCount());
- prop.putNum("connectionsMax", httpd.getMaxSessionCount());
-
++
+ //prop.putNum("connectionsActive", httpd.getJobCount());
+ //prop.putNum("connectionsMax", httpd.getMaxSessionCount());
-
++
// Queue information
final int loaderJobCount = sb.crawlQueues.workerSize();
- final int loaderMaxCount = Integer.parseInt(sb.getConfig(SwitchboardConstants.CRAWLER_THREADS_ACTIVE_MAX, "10"));
- final int loaderPercent = (loaderMaxCount==0)?0:loaderJobCount*100/loaderMaxCount;
+ final int loaderMaxCount = sb.getConfigInt(SwitchboardConstants.CRAWLER_THREADS_ACTIVE_MAX, 10);
+ final int loaderPercent = (loaderMaxCount == 0) ? 0 : loaderJobCount * 100 / loaderMaxCount;
prop.putNum("loaderQueueSize", loaderJobCount);
- prop.putNum("loaderQueueMax", loaderMaxCount);
- prop.put("loaderQueuePercent", (loaderPercent>100) ? 100 : loaderPercent);
-
- prop.putNum("localCrawlQueueSize", sb.getThread(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL).getJobCount());
- prop.put("localCrawlPaused",sb.crawlJobIsPaused(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL) ? "1" : "0");
-
- prop.putNum("remoteTriggeredCrawlQueueSize", sb.getThread(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL).getJobCount());
- prop.put("remoteTriggeredCrawlPaused",sb.crawlJobIsPaused(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL) ? "1" : "0");
-
+ prop.putNum("loaderQueueMax", loaderMaxCount);
+ prop.put("loaderQueuePercent", (loaderPercent > 100) ? 100 : loaderPercent);
+
+ prop.putNum("localCrawlQueueSize", sb
+ .getThread(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL)
+ .getJobCount());
+ prop.put("localCrawlPaused", sb.crawlJobIsPaused(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL)
+ ? "1"
+ : "0");
+
+ prop.putNum(
+ "remoteTriggeredCrawlQueueSize",
+ sb.getThread(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL).getJobCount());
+ prop.put(
+ "remoteTriggeredCrawlPaused",
+ sb.crawlJobIsPaused(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL) ? "1" : "0");
+
prop.putNum("stackCrawlQueueSize", sb.crawlStacker.size());
// return rewrite properties
diff --cc source/de/anomic/http/server/HTTPDProxyHandler.java
index 4572fd210,137fab708..a1b8fd6b3
--- a/source/de/anomic/http/server/HTTPDProxyHandler.java
+++ b/source/de/anomic/http/server/HTTPDProxyHandler.java
@@@ -474,16 -478,16 +478,16 @@@ public final class HTTPDProxyHandler
&& (remotePath.startsWith("/env"))
&& ((pos = yAddress.indexOf('/')) != -1)
) yAddress = yAddress.substring(0, yAddress.indexOf('/'));
-
+
modifyProxyHeaders(requestHeader, httpVer);
-
+
final String connectHost = hostPart(host, port, yAddress);
final String getUrl = "http://"+ connectHost + remotePath;
-
+
requestHeader.remove(HeaderFramework.HOST);
-
-
++
final HTTPClient client = setupHttpClient(requestHeader, connectHost);
-
+
// send request
try {
client.GET(getUrl);
@@@ -566,9 -575,9 +575,9 @@@
final boolean storeHTCache = response.profile().storeHTCache();
final String supportError = TextParser.supports(response.url(), response.getMimeType());
-- if(AugmentedHtmlStream.supportsMime(responseHeader.mime())) {
- outStream = new AugmentedHtmlStream(outStream, responseHeader.getCharSet());
++ if (AugmentedHtmlStream.supportsMime(responseHeader.mime())) {
+ outStream = new AugmentedHtmlStream(outStream, responseHeader.getCharSet(), url, requestHeader);
- }
+ }
if (
/*
* Now we store the response into the htcache directory if
@@@ -638,6 -647,7 +647,7 @@@
}
outStream.close();
-
++
if (chunkedOut != null) {
chunkedOut.finish();
chunkedOut.flush();
@@@ -724,10 -734,10 +734,10 @@@
HTTPDemon.sendRespondHeader(conProp,respond,httpVer,203,cachedResponseHeader);
//respondHeader(respond, "203 OK", cachedResponseHeader); // respond with 'non-authoritative'
-- if(AugmentedHtmlStream.supportsMime(cachedResponseHeader.mime())) {
- respond = new AugmentedHtmlStream(respond, cachedResponseHeader.getCharSet());
- }
-
- respond = new AugmentedHtmlStream(respond, cachedResponseHeader.getCharSet(), url, requestHeader);
++ if (AugmentedHtmlStream.supportsMime(cachedResponseHeader.mime())) {
++ respond = new AugmentedHtmlStream(respond, cachedResponseHeader.getCharSet(), url, requestHeader);
+ }
-
++
// send also the complete body now from the cache
// simply read the file and transfer to out socket
FileUtils.copy(cacheEntry, respond);
@@@ -1168,14 -1179,14 +1180,14 @@@
headers.remove(RequestHeader.PROXY_CONNECTION);
headers.remove(RequestHeader.PROXY_AUTHENTICATE);
headers.remove(RequestHeader.PROXY_AUTHORIZATION);
-
+
// special headers inserted by squid
headers.remove(RequestHeader.X_CACHE);
- headers.remove(RequestHeader.X_CACHE_LOOKUP);
-
+ headers.remove(RequestHeader.X_CACHE_LOOKUP);
+
// remove transfer encoding header
- headers.remove(HeaderFramework.TRANSFER_ENCODING);
+ //headers.remove(HeaderFramework.TRANSFER_ENCODING);
-
+
//removing yacy status headers
headers.remove(HeaderFramework.X_YACY_KEEP_ALIVE_REQUEST_COUNT);
headers.remove(HeaderFramework.X_YACY_ORIGINAL_REQUEST_LINE);
diff --cc source/net/yacy/http/AbstractRemoteHandler.java
index 1fc17ecae,000000000..6a5748373
mode 100644,000000..100644
--- a/source/net/yacy/http/AbstractRemoteHandler.java
+++ b/source/net/yacy/http/AbstractRemoteHandler.java
@@@ -1,76 -1,0 +1,76 @@@
+//
+// AbstractRemoteHandler
+// Copyright 2011 by Florian Richter
+// First released 2011 at http://yacy.net
+//
+// $LastChangedDate$
+// $LastChangedRevision$
+// $LastChangedBy$
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program in the file lgpl21.txt
+// If not, see <http://www.gnu.org/licenses/>.
+//
+
+package net.yacy.http;
+
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
++import net.yacy.search.Switchboard;
++
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.handler.AbstractHandler;
+
- import de.anomic.search.Switchboard;
-
+/**
+ * abstract jetty http handler
+ * only request to remote hosts (proxy requests) are processed by derived classes
+ */
+abstract public class AbstractRemoteHandler extends AbstractHandler implements Handler {
+
+ protected Switchboard sb = null;
+
+ private List<String> localVirtualHostNames;
+
+ @Override
+ protected void doStart() {
+ sb = Switchboard.getSwitchboard();
+
+ localVirtualHostNames = new LinkedList<String>();
+ localVirtualHostNames.add("localpeer");
+ localVirtualHostNames.add("localhost");
+ }
+
+ abstract public void handleRemote(String target, Request baseRequest, HttpServletRequest request,
+ HttpServletResponse response) throws IOException, ServletException;
+
+ @Override
+ public void handle(String target, Request baseRequest, HttpServletRequest request,
+ HttpServletResponse response) throws IOException, ServletException {
+ String host = request.getHeader("Host");
+ if(host == null) return; // no proxy request, continue processing by handlers
+ int hostSplitPos = host.indexOf(':');
+ String hostOnly = hostSplitPos<0 ? host : host.substring(0, hostSplitPos);
+
+ if(localVirtualHostNames.contains(hostOnly)) return; // no proxy request, continue processing by handlers
+
+ handleRemote(target, baseRequest, request, response);
+ }
+
+}
diff --cc source/net/yacy/http/HttpServer.java
index 57ec1fee4,000000000..d8b2e3e24
mode 100644,000000..100644
--- a/source/net/yacy/http/HttpServer.java
+++ b/source/net/yacy/http/HttpServer.java
@@@ -1,108 -1,0 +1,108 @@@
+//
+// HttpServer
+// Copyright 2011 by Florian Richter
+// First released 13.04.2011 at http://yacy.net
+//
+// $LastChangedDate$
+// $LastChangedRevision$
+// $LastChangedBy$
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program in the file lgpl21.txt
+// If not, see <http://www.gnu.org/licenses/>.
+//
+
+package net.yacy.http;
+
++import net.yacy.search.Switchboard;
++
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.ContextHandler;
+import org.eclipse.jetty.server.handler.DefaultHandler;
- import org.eclipse.jetty.server.handler.ErrorHandler;
+import org.eclipse.jetty.server.handler.HandlerList;
+import org.eclipse.jetty.server.handler.ResourceHandler;
+import org.eclipse.jetty.server.nio.SelectChannelConnector;
+
- import de.anomic.search.Switchboard;
+
+/**
+ * class to embedded jetty http server into YaCy
+ */
+public class HttpServer {
+
+ private Server server = new Server();
+
+ /**
+ * @param port TCP Port to listen for http requests
+ */
+ public HttpServer(int port) {
+ Switchboard sb = Switchboard.getSwitchboard();
+ server = new Server();
+ SelectChannelConnector connector = new SelectChannelConnector();
+ connector.setPort(port);
+ //connector.setThreadPool(new QueuedThreadPool(20));
+ server.addConnector(connector);
+
+ YacyDomainHandler domainHandler = new YacyDomainHandler();
+ domainHandler.setAlternativeResolver(sb.peers);
+
+ ResourceHandler resource_handler = new ResourceHandler();
+ resource_handler.setDirectoriesListed(true);
+ resource_handler.setWelcomeFiles(new String[]{ "index.html" });
+
+ resource_handler.setResourceBase("htroot/");
+
+ HandlerList handlers = new HandlerList();
+ handlers.setHandlers(new Handler[]
+ { domainHandler, new ProxyCacheHandler(), new ProxyHandler(), new RewriteHandler(),
+ new SSIHandler(new TemplateHandler()),
+ resource_handler, new DefaultHandler() });
+
+ YaCySecurityHandler securityHandler = new YaCySecurityHandler();
+ securityHandler.setLoginService(new YaCyLoginService());
+ securityHandler.setRealmName("YaCy Admin Interface");
+ securityHandler.setHandler(new CrashProtectionHandler(handlers));
+
+ // context handler for dispatcher and security
+ ContextHandler context = new ContextHandler();
+ context.setContextPath("/");
+ context.setHandler(securityHandler);
+
+ server.setHandler(context);
+ }
+
+ /**
+ * start http server
+ */
+ public void start() throws Exception {
+ server.start();
+ }
+
+ /**
+ * stop http server and wait for it
+ */
+ public void stop() throws Exception {
+ server.stop();
+ server.join();
+ }
+
+ /**
+ * just for testing and debugging
+ */
+ public static void main(String[] args) throws Exception {
+ HttpServer server = new HttpServer(8090);
+ server.start();
+ server.stop();
+ }
+
+}
diff --cc source/net/yacy/http/ProxyCacheHandler.java
index c78a7101b,000000000..c73105ad6
mode 100644,000000..100644
--- a/source/net/yacy/http/ProxyCacheHandler.java
+++ b/source/net/yacy/http/ProxyCacheHandler.java
@@@ -1,106 -1,0 +1,106 @@@
+//
+// ProxyCacheHandler
+// Copyright 2004 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany
+// Copyright 2011 by Florian Richter
+// First released 2011 at http://yacy.net
+//
+// $LastChangedDate$
+// $LastChangedRevision$
+// $LastChangedBy$
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program in the file lgpl21.txt
+// If not, see <http://www.gnu.org/licenses/>.
+//
+
+package net.yacy.http;
+
+import java.io.IOException;
+import java.util.Map.Entry;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import net.yacy.cora.protocol.RequestHeader;
+import net.yacy.cora.protocol.ResponseHeader;
+import net.yacy.kelondro.data.meta.DigestURI;
+
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.server.Request;
+
++import de.anomic.crawler.Cache;
+import de.anomic.crawler.retrieval.Response;
- import de.anomic.http.client.Cache;
+
+/**
+ * jetty http handler
+ * serves pages from cache if available and valid
+ */
+public class ProxyCacheHandler extends AbstractRemoteHandler implements Handler {
+
+
+ private void handleRequestFromCache(HttpServletRequest request, HttpServletResponse response, ResponseHeader cachedResponseHeader, byte[] content) throws IOException {
+ System.err.println("handle from cache");
+ // TODO: check if-modified
+ for(Entry<String, String> entry: cachedResponseHeader.entrySet()) {
+ response.addHeader(entry.getKey(), entry.getValue());
+ }
+ response.setStatus(HttpServletResponse.SC_NON_AUTHORITATIVE_INFORMATION);
+ response.getOutputStream().write(content);
+ // we handled this request, break out of handler chain
+ Request base_request = (request instanceof Request) ? (Request)request:HttpConnection.getCurrentConnection().getRequest();
+ base_request.setHandled(true);
+ }
+
+ @Override
+ public void handleRemote(String target, Request baseRequest,
+ HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException {
+ if(request.getMethod().equals("GET")) {
+ String queryString = request.getQueryString()!=null ? "?" + request.getQueryString() : "";
+ DigestURI url = new DigestURI(request.getRequestURL().toString() + queryString);
- ResponseHeader cachedResponseHeader = Cache.getResponseHeader(url);
++ ResponseHeader cachedResponseHeader = Cache.getResponseHeader(url.hash());
+
+ if(cachedResponseHeader != null) {
+ RequestHeader proxyHeaders = ProxyHandler.convertHeaderFromJetty(request);
+ // TODO: this convertion is only necessary
+ final de.anomic.crawler.retrieval.Request yacyRequest = new de.anomic.crawler.retrieval.Request(
+ null,
+ url,
+ proxyHeaders.referer() == null ? null : new DigestURI(proxyHeaders.referer()).hash(),
+ "",
+ cachedResponseHeader.lastModified(),
+ sb.crawler.defaultProxyProfile.handle(),
+ 0,
+ 0,
+ 0,
+ 0);
+
+ final Response cachedResponse = new Response(
+ yacyRequest,
+ proxyHeaders,
+ cachedResponseHeader,
- "200 OK",
- sb.crawler.defaultProxyProfile
++ sb.crawler.defaultProxyProfile,
++ false
+ );
- byte[] cacheContent = Cache.getContent(url);
++ byte[] cacheContent = Cache.getContent(url.hash());
+ if (cacheContent != null && cachedResponse.isFreshForProxy()) {
+ handleRequestFromCache(request, response, cachedResponseHeader, cacheContent);
+ }
+ }
+
+ }
+ }
+
+}
diff --cc source/net/yacy/http/ProxyHandler.java
index e7744b522,000000000..cd3c70c07
mode 100644,000000..100644
--- a/source/net/yacy/http/ProxyHandler.java
+++ b/source/net/yacy/http/ProxyHandler.java
@@@ -1,242 -1,0 +1,241 @@@
+//
+// ProxyHandler
+// Copyright 2004 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany
+// Copyright 2011 by Florian Richter
+// First released 2011 at http://yacy.net
+//
+// $LastChangedDate$
+// $LastChangedRevision$
+// $LastChangedBy$
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program in the file lgpl21.txt
+// If not, see <http://www.gnu.org/licenses/>.
+//
+
+package net.yacy.http;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.SocketException;
+import java.util.Enumeration;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
- import net.yacy.cora.protocol.HeaderFramework;
+import net.yacy.cora.protocol.RequestHeader;
+import net.yacy.cora.protocol.ResponseHeader;
+import net.yacy.cora.protocol.http.HTTPClient;
+import net.yacy.document.TextParser;
+import net.yacy.kelondro.data.meta.DigestURI;
+
+import org.apache.http.Header;
+import org.apache.http.HttpResponse;
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.server.Request;
+
++import de.anomic.crawler.Cache;
+import de.anomic.crawler.retrieval.Response;
- import de.anomic.http.client.Cache;
+import de.anomic.http.server.MultiOutputStream;
+
+/**
+ * jetty http handler
+ * proxies request, caches responses and adds urls to crawler
+ */
+public class ProxyHandler extends AbstractRemoteHandler implements Handler {
+
+ static RequestHeader convertHeaderFromJetty(HttpServletRequest request) {
+ RequestHeader result = new RequestHeader();
+ @SuppressWarnings("unchecked")
+ Enumeration<String> headerNames = request.getHeaderNames();
+ while(headerNames.hasMoreElements()) {
+ String headerName = headerNames.nextElement();
+ @SuppressWarnings("unchecked")
+ Enumeration<String> headers = request.getHeaders(headerName);
+ while(headers.hasMoreElements()) {
+ String header = headers.nextElement();
+ result.add(headerName, header);
+ }
+ }
+ return result;
+ }
+
+ static void convertHeaderToJetty(HttpResponse in, HttpServletResponse out) {
+ for(Header h: in.getAllHeaders()) {
+ out.addHeader(h.getName(), h.getValue());
+ }
+ }
+
+ private void cleanResponseHeader(HttpResponse headers) {
+ headers.removeHeaders("Content-Encoding");
+ headers.removeHeaders("Content-Length");
+ }
+
+ @Override
+ public void handleRemote(String target, Request baseRequest, HttpServletRequest request,
+ HttpServletResponse response) throws IOException, ServletException {
+
+ RequestHeader proxyHeaders = convertHeaderFromJetty(request);
+ proxyHeaders.add(RequestHeader.VIA, "YaCy");
+ proxyHeaders.remove(RequestHeader.KEEP_ALIVE);
+ proxyHeaders.remove(RequestHeader.CONTENT_LENGTH);
+
+ final HTTPClient client = new HTTPClient();
+ int timeout = 60000;
+ client.setTimout(timeout);
+ client.setHeader(proxyHeaders.entrySet());
+ client.setRedirecting(false);
+ // send request
+ try {
+ String queryString = request.getQueryString()!=null ? "?" + request.getQueryString() : "";
+ String url = request.getRequestURL().toString() + queryString;
+ if (request.getMethod().equals("GET")) {
+ client.GET(url);
+ } else if (request.getMethod().equals("POST")) {
+ client.POST(url, request.getInputStream(), request.getContentLength());
+ } else if (request.getMethod().equals("HEAD")) {
+ client.HEADResponse(url);
+ } else {
+ throw new ServletException("Unsupported Request Method");
+ }
+ HttpResponse responseHeader = client.getHttpResponse();
- final ResponseHeader responseHeaderLegacy = new ResponseHeader(client.getHttpResponse().getAllHeaders());
++ final ResponseHeader responseHeaderLegacy = new ResponseHeader(200, client.getHttpResponse().getAllHeaders());
+
+ cleanResponseHeader(responseHeader);
+
+ // TODO: is this fast, if not, use value from ProxyCacheHandler
+ DigestURI digestURI = new DigestURI(url);
- ResponseHeader cachedResponseHeader = Cache.getResponseHeader(digestURI);
++ ResponseHeader cachedResponseHeader = Cache.getResponseHeader(digestURI.hash());
+
+ // the cache does either not exist or is (supposed to be) stale
+ long sizeBeforeDelete = -1;
+ if (cachedResponseHeader != null) {
+ // delete the cache
- ResponseHeader rh = Cache.getResponseHeader(digestURI);
++ ResponseHeader rh = Cache.getResponseHeader(digestURI.hash());
+ if (rh != null && (sizeBeforeDelete = rh.getContentLength()) == 0) {
- byte[] b = Cache.getContent(new DigestURI(url));
++ byte[] b = Cache.getContent(new DigestURI(url).hash());
+ if (b != null) sizeBeforeDelete = b.length;
+ }
- Cache.delete(digestURI);
++ Cache.delete(digestURI.hash());
+ // log refresh miss
+ }
+
+ // reserver cache entry
+ final de.anomic.crawler.retrieval.Request yacyRequest = new de.anomic.crawler.retrieval.Request(
+ null,
+ digestURI,
+ null, //requestHeader.referer() == null ? null : new DigestURI(requestHeader.referer()).hash(),
+ "",
+ responseHeaderLegacy.lastModified(),
+ sb.crawler.defaultProxyProfile.handle(),
+ 0,
+ 0,
+ 0,
+ 0); //sizeBeforeDelete < 0 ? 0 : sizeBeforeDelete);
+ final Response yacyResponse = new Response(
+ yacyRequest,
+ null,
+ responseHeaderLegacy,
- Integer.toString(client.getHttpResponse().getStatusLine().getStatusCode()),
- sb.crawler.defaultProxyProfile
++ sb.crawler.defaultProxyProfile,
++ false
+ );
+
+ final String storeError = yacyResponse.shallStoreCacheForProxy();
+ final boolean storeHTCache = yacyResponse.profile().storeHTCache();
+ final String supportError = TextParser.supports(yacyResponse.url(), yacyResponse.getMimeType());
+
+ if (
+ /*
+ * Now we store the response into the htcache directory if
+ * a) the response is cacheable AND
+ */
+ (storeError == null) &&
+ /*
+ * b) the user has configured to use the htcache OR
+ * c) the content should be indexed
+ */
+ ((storeHTCache) || (supportError != null))
+ ) {
+ // we don't write actually into a file, only to RAM, and schedule writing the file.
+ int l = responseHeaderLegacy.size();
+ final ByteArrayOutputStream byteStream = new ByteArrayOutputStream((l < 32) ? 32 : l);
+
+ final OutputStream toClientAndMemory = new MultiOutputStream(new OutputStream[] {response.getOutputStream(), byteStream});
+
+ client.writeTo(toClientAndMemory);
+
+ // cached bytes
+ byte[] cacheArray;
+ if (byteStream.size() > 0) {
+ cacheArray = byteStream.toByteArray();
+ } else {
+ cacheArray = null;
+ }
+ //if (log.isFine()) log.logFine(reqID +" writeContent of " + url + " produced cacheArray = " + ((cacheArray == null) ? "null" : ("size=" + cacheArray.length)));
+
+ if (sizeBeforeDelete == -1) {
+ // totally fresh file
+ yacyResponse.setContent(cacheArray);
+ try {
+ Cache.store(yacyResponse.url(), yacyResponse.getResponseHeader(), cacheArray);
+ sb.toIndexer(yacyResponse);
+ } catch (IOException e) {
+ //log.logWarning("cannot write " + response.url() + " to Cache (1): " + e.getMessage(), e);
+ }
+ // log cache miss
+ } else if (cacheArray != null && sizeBeforeDelete == cacheArray.length) {
+ // TODO: what should happen here?
+ // before we came here we deleted a cache entry
+ cacheArray = null;
+ //cacheManager.push(cacheEntry); // unnecessary update
+ // log cache refresh fail miss
+ } else {
+ // before we came here we deleted a cache entry
+ yacyResponse.setContent(cacheArray);
+ try {
+ Cache.store(yacyResponse.url(), yacyResponse.getResponseHeader(), cacheArray);
+ sb.toIndexer(yacyResponse);
+ } catch (IOException e) {
+ //log.logWarning("cannot write " + response.url() + " to Cache (2): " + e.getMessage(), e);
+ }
+ // log refresh cache miss
+ }
+
+ } else {
+ // no caching
+ /*if (log.isFine()) log.logFine(reqID +" "+ url.toString() + " not cached." +
+ " StoreError=" + ((storeError==null)?"None":storeError) +
+ " StoreHTCache=" + storeHTCache +
+ " SupportError=" + supportError);*/
+ convertHeaderToJetty(responseHeader, response);
+ //response.setContentType(responseHeader.getFirstHeader(HeaderFramework.CONTENT_TYPE).getValue());
+ response.setStatus(responseHeader.getStatusLine().getStatusCode());
+
+ client.writeTo(response.getOutputStream());
+ }
+ } catch(SocketException se) {
+ throw new ServletException("Socket Exception: " + se.getMessage());
+ } finally {
+ client.finish();
+ }
+
+ // we handled this request, break out of handler chain
+ Request base_request = (request instanceof Request) ? (Request)request:HttpConnection.getCurrentConnection().getRequest();
+ base_request.setHandled(true);
+ }
+
+
+}
diff --cc source/net/yacy/http/TemplateHandler.java
index c19d1b4fa,000000000..cab2da30b
mode 100644,000000..100644
--- a/source/net/yacy/http/TemplateHandler.java
+++ b/source/net/yacy/http/TemplateHandler.java
@@@ -1,328 -1,0 +1,317 @@@
+//
+// TemplateHandler
+// Copyright 2005 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany
+// Copyright 2011 by Florian Richter
+// First released 13.04.2011 at http://yacy.net
+//
+// $LastChangedDate$
+// $LastChangedRevision$
+// $LastChangedBy$
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program in the file lgpl21.txt
+// If not, see <http://www.gnu.org/licenses/>.
+//
+
+package net.yacy.http;
+
+import java.awt.Image;
+import java.awt.image.BufferedImage;
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.ref.SoftReference;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.concurrent.ConcurrentHashMap;
+
- import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import net.yacy.cora.date.GenericFormatter;
++import net.yacy.cora.document.Classification;
+import net.yacy.cora.protocol.HeaderFramework;
+import net.yacy.cora.protocol.RequestHeader;
+import net.yacy.kelondro.logging.Log;
+import net.yacy.kelondro.util.ByteBuffer;
+import net.yacy.kelondro.util.FileUtils;
+import net.yacy.kelondro.util.MemoryControl;
++import net.yacy.peers.Seed;
++import net.yacy.peers.graphics.EncodedImage;
++import net.yacy.peers.operation.yacyBuildProperties;
++import net.yacy.search.Switchboard;
+import net.yacy.visualization.RasterPlotter;
+
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.handler.AbstractHandler;
+
- import de.anomic.data.MimeTable;
+import de.anomic.http.server.TemplateEngine;
- import de.anomic.search.Switchboard;
+import de.anomic.server.serverClassLoader;
+import de.anomic.server.serverCore;
+import de.anomic.server.serverObjects;
+import de.anomic.server.serverSwitch;
+import de.anomic.server.servletProperties;
- import de.anomic.yacy.yacyBuildProperties;
- import de.anomic.yacy.yacySeed;
- import de.anomic.yacy.graphics.EncodedImage;
+
+/**
+ * jetty http handler:
+ *
+ * Handles classic yacy servlets with templates
+ */
+public class TemplateHandler extends AbstractHandler implements Handler {
+
+ private String htLocalePath = "DATA/LOCALE/htroot";
+ private String htDefaultPath = "htroot";
+ private String htDocsPath = "DATA/HTDOCS";
+
+ private static final serverClassLoader provider = new serverClassLoader(/*this.getClass().getClassLoader()*/);
+
- boolean useTemplateCache = false;
- private ConcurrentHashMap<File, SoftReference<TemplateCacheEntry>> templateCache = null;
+ private ConcurrentHashMap<File, SoftReference<Method>> templateMethodCache = null;
+
+ @Override
+ protected void doStart() throws Exception {
+ super.doStart();
- // TODO create template cache
- templateCache = (useTemplateCache)? new ConcurrentHashMap<File, SoftReference<TemplateCacheEntry>>() : new ConcurrentHashMap<File, SoftReference<TemplateCacheEntry>>(0);
- templateMethodCache = (useTemplateCache) ? new ConcurrentHashMap<File, SoftReference<Method>>() : new ConcurrentHashMap<File, SoftReference<Method>>(0);
++ templateMethodCache = new ConcurrentHashMap<File, SoftReference<Method>>();
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ super.doStop();
- // TODO destroy template cache?
+ }
+
+ /** Returns a path to the localized or default file according to the parameter localeSelection
+ * @param path relative from htroot
+ * @param localeSelection language of localized file; locale.language from switchboard is used if localeSelection.equals("") */
+ public File getLocalizedFile(final String path, final String localeSelection){
+ if (!(localeSelection.equals("default"))) {
+ final File localePath = new File(htLocalePath, localeSelection + '/' + path);
+ if (localePath.exists()) return localePath; // avoid "NoSuchFile" troubles if the "localeSelection" is misspelled
+ }
+
+ File docsPath = new File(htDocsPath, path);
+ if (docsPath.exists()) return docsPath;
+ return new File(htDefaultPath, path);
+ }
+
+ private final File rewriteClassFile(final File template) {
+ try {
+ String f = template.getCanonicalPath();
+ final int p = f.lastIndexOf('.');
+ if (p < 0) return null;
+ f = f.substring(0, p) + ".class";
+ //System.out.println("constructed class path " + f);
+ final File cf = new File(f);
+ if (cf.exists()) return cf;
+ return null;
+ } catch (final IOException e) {
+ return null;
+ }
+ }
+
+ private final Method rewriteMethod(final File classFile) throws InvocationTargetException {
+ Method m = null;
+ // now make a class out of the stream
+ try {
- if (useTemplateCache) {
- final SoftReference<Method> ref = templateMethodCache.get(classFile);
- if (ref != null) {
- m = ref.get();
- if (m == null) {
- templateMethodCache.remove(classFile);
- } else {
- return m;
- }
- }
++ final SoftReference<Method> ref = templateMethodCache.get(classFile);
++ if (ref != null) {
++ m = ref.get();
++ if (m == null) {
++ templateMethodCache.remove(classFile);
++ } else {
++ return m;
++ }
+ }
+
+ final Class<?> c = provider.loadClass(classFile);
+ final Class<?>[] params = new Class[] {
+ RequestHeader.class,
+ serverObjects.class,
+ serverSwitch.class };
+ m = c.getMethod("respond", params);
+
- if (useTemplateCache) {
- // storing the method into the cache
- final SoftReference<Method> ref = new SoftReference<Method>(m);
- templateMethodCache.put(classFile, ref);
- }
++ // store the method into the cache
++ templateMethodCache.put(classFile, new SoftReference<Method>(m));
+
+ } catch (final ClassNotFoundException e) {
+ Log.logSevere("TemplateHandler", "class " + classFile + " is missing:" + e.getMessage());
+ throw new InvocationTargetException(e, "class " + classFile + " is missing:" + e.getMessage());
+ } catch (final NoSuchMethodException e) {
+ Log.logSevere("TemplateHandler", "method 'respond' not found in class " + classFile + ": " + e.getMessage());
+ throw new InvocationTargetException(e, "method 'respond' not found in class " + classFile + ": " + e.getMessage());
+ }
+ return m;
+ }
+
+
+ private final Object invokeServlet(final File targetClass, final RequestHeader request, final serverObjects args) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
+ return rewriteMethod(targetClass).invoke(null, new Object[] {request, args, Switchboard.getSwitchboard()}); // add switchboard
+ }
+
+ private RequestHeader generateLegacyRequestHeader(HttpServletRequest request, String target, String targetExt) {
+ RequestHeader legacyRequestHeader = new RequestHeader();
+ @SuppressWarnings("unchecked")
+ Enumeration<String> headers = request.getHeaderNames();
+ while (headers.hasMoreElements()) {
+ String headerName = headers.nextElement();
+ @SuppressWarnings("unchecked")
+ Enumeration<String> header = request.getHeaders(headerName);
+ while(header.hasMoreElements())
+ legacyRequestHeader.add(headerName, header.nextElement());
+ }
+
+ legacyRequestHeader.put(HeaderFramework.CONNECTION_PROP_CLIENTIP, request.getRemoteAddr());
+ legacyRequestHeader.put(HeaderFramework.CONNECTION_PROP_PATH, target);
+ legacyRequestHeader.put(HeaderFramework.CONNECTION_PROP_EXT, targetExt);
+
+ return legacyRequestHeader;
+ }
+
+ @Override
+ public void handle(String target, Request baseRequest, HttpServletRequest request,
+ HttpServletResponse response) throws IOException, ServletException {
+ Switchboard sb = Switchboard.getSwitchboard();
+
+ System.err.println("Page: " + target);
+
+ String localeSelection = "default";
+ File targetFile = getLocalizedFile(target, localeSelection);
+ File targetClass = rewriteClassFile(new File(htDefaultPath, target));
+ String targetExt = target.substring(target.lastIndexOf('.') + 1, target.length());
+
+ if ((targetClass != null)) {
+ serverObjects args = new serverObjects();
+ @SuppressWarnings("unchecked")
+ Enumeration<String> argNames = request.getParameterNames();
+ while (argNames.hasMoreElements()) {
+ String argName = argNames.nextElement();
+ args.put(argName, request.getParameter(argName));
+ }
+ RequestHeader legacyRequestHeader = generateLegacyRequestHeader(request, target, targetExt);
+
+ Object tmp;
+ try {
+ tmp = invokeServlet(targetClass, legacyRequestHeader, args);
+ } catch (InvocationTargetException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ throw new ServletException();
+ } catch (IllegalArgumentException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ throw new ServletException();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ throw new ServletException();
+ }
+
+ if ( tmp instanceof RasterPlotter || tmp instanceof EncodedImage || tmp instanceof Image) {
+
+ ByteBuffer result = null;
+
+ if (tmp instanceof RasterPlotter) {
+ final RasterPlotter yp = (RasterPlotter) tmp;
+ // send an image to client
+ result = RasterPlotter.exportImage(yp.getImage(), "png");
+ }
+ if (tmp instanceof EncodedImage) {
+ final EncodedImage yp = (EncodedImage) tmp;
+ result = yp.getImage();
+ }
+
+ if (tmp instanceof Image) {
+ final Image i = (Image) tmp;
+
+ // generate an byte array from the generated image
+ int width = i.getWidth(null); if (width < 0) width = 96; // bad hack
+ int height = i.getHeight(null); if (height < 0) height = 96; // bad hack
+ final BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+ bi.createGraphics().drawImage(i, 0, 0, width, height, null);
+ result = RasterPlotter.exportImage(bi, targetExt);
+ }
+
- final String mimeType = MimeTable.ext2mime(targetExt, "text/html");
++ final String mimeType = Classification.ext2mime(targetExt, "text/html");
+ response.setContentType(mimeType);
+ response.setContentLength(result.length());
+ response.setStatus(HttpServletResponse.SC_OK);
+
+ result.writeTo(response.getOutputStream());
+
+ // we handled this request, break out of handler chain
+ Request base_request = (request instanceof Request) ? (Request)request:HttpConnection.getCurrentConnection().getRequest();
+ base_request.setHandled(true);
+
+ return;
+ }
+
+
+ servletProperties templatePatterns = null;
+ if (tmp == null) {
+ // if no args given, then tp will be an empty Hashtable object (not null)
+ templatePatterns = new servletProperties();
+ } else if (tmp instanceof servletProperties) {
+ templatePatterns = (servletProperties) tmp;
+ } else {
+ templatePatterns = new servletProperties((serverObjects) tmp);
+ }
+ // add the application version, the uptime and the client name to every rewrite table
+ templatePatterns.put(servletProperties.PEER_STAT_VERSION, yacyBuildProperties.getVersion());
+ templatePatterns.put(servletProperties.PEER_STAT_UPTIME, ((System.currentTimeMillis() - serverCore.startupTime) / 1000) / 60); // uptime in minutes
+ templatePatterns.putHTML(servletProperties.PEER_STAT_CLIENTNAME, sb.peers.mySeed().getName());
+ templatePatterns.putHTML(servletProperties.PEER_STAT_CLIENTID, sb.peers.myID());
+ templatePatterns.put(servletProperties.PEER_STAT_MYTIME, GenericFormatter.SHORT_SECOND_FORMATTER.format());
- yacySeed myPeer = sb.peers.mySeed();
++ Seed myPeer = sb.peers.mySeed();
+ templatePatterns.put("newpeer", myPeer.getAge() >= 1 ? 0 : 1);
+ templatePatterns.putHTML("newpeer_peerhash", myPeer.hash);
+
+ if(targetFile.exists() && targetFile.isFile() && targetFile.canRead()) {
- String mimeType = MimeTable.ext2mime(targetExt, "text/html");
++ String mimeType = Classification.ext2mime(targetExt, "text/html");
+
+ InputStream fis = null;
+ long fileSize = targetFile.length();
+
+ if (fileSize <= Math.min(4 * 1024 * 1204, MemoryControl.available() / 100)) {
+ // read file completely into ram, avoid that too many files are open at the same time
+ fis = new ByteArrayInputStream(FileUtils.read(targetFile));
+ } else {
+ fis = new BufferedInputStream(new FileInputStream(targetFile));
+ }
+
+ // set response header
+ response.setContentType(mimeType);
+ response.setStatus(HttpServletResponse.SC_OK);
+
+ // apply templates
+ TemplateEngine.writeTemplate(fis, response.getOutputStream(), templatePatterns, "-UNRESOLVED_PATTERN-".getBytes("UTF-8"));
+ fis.close();
+
+ // we handled this request, break out of handler chain
+ Request base_request = (request instanceof Request) ? (Request)request:HttpConnection.getCurrentConnection().getRequest();
+ base_request.setHandled(true);
+ }
+ }
+ }
+
+ protected final class TemplateCacheEntry {
+ Date lastModified;
+ byte[] content;
+ }
+
+}
diff --cc source/net/yacy/http/YaCyLoginService.java
index a08e830d3,000000000..6a902ba6b
mode 100644,000000..100644
--- a/source/net/yacy/http/YaCyLoginService.java
+++ b/source/net/yacy/http/YaCyLoginService.java
@@@ -1,69 -1,0 +1,68 @@@
+//
+// YaCyLoginService
+// Copyright 2011 by Florian Richter
+// First released 16.04.2011 at http://yacy.net
+//
+// $LastChangedDate$
+// $LastChangedRevision$
+// $LastChangedBy$
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program in the file lgpl21.txt
+// If not, see <http://www.gnu.org/licenses/>.
+//
+
+package net.yacy.http;
+
+import java.io.IOException;
+import java.security.Principal;
+
+import javax.security.auth.Subject;
+
++import net.yacy.search.Switchboard;
++
+import org.eclipse.jetty.http.security.Credential;
+import org.eclipse.jetty.security.IdentityService;
+import org.eclipse.jetty.security.MappedLoginService;
+import org.eclipse.jetty.server.UserIdentity;
+
- import de.anomic.search.Switchboard;
-
-
+/**
+ * jetty login service, provides one admin user
+ */
+public class YaCyLoginService extends MappedLoginService {
+
+ @Override
+ protected UserIdentity loadUser(String username) {
+ if(username.equals("admin")) {
+ // TODO: implement legacy credentials
+ final Switchboard sb = Switchboard.getSwitchboard();
+ final String adminAccountBase64MD5 = sb.getConfig(YaCyLegacyCredential.ADMIN_ACCOUNT_B64MD5, "");
+ Credential credential = YaCyLegacyCredential.getCredentialsFromConfig(adminAccountBase64MD5);
+ Principal userPrincipal = new MappedLoginService.KnownUser("admin", credential);
+ Subject subject = new Subject();
+ subject.getPrincipals().add(userPrincipal);
+ subject.getPrivateCredentials().add(credential);
+ subject.setReadOnly();
+ IdentityService is = getIdentityService();
+ return is.newUserIdentity(subject, userPrincipal, new String[]{"admin"});
+ }
+ return null;
+ }
+
+ @Override
+ protected void loadUsers() throws IOException {
+ // don't load any users into MappedLoginService on startup
+ // we use loadUser for dynamic checking
+ }
+
+}
diff --cc source/net/yacy/http/YaCySecurityHandler.java
index a0358fa47,000000000..08ab4d254
mode 100644,000000..100644
--- a/source/net/yacy/http/YaCySecurityHandler.java
+++ b/source/net/yacy/http/YaCySecurityHandler.java
@@@ -1,88 -1,0 +1,87 @@@
+//
+// YaCySecurityHandler
+// Copyright 2011 by Florian Richter
+// First released 16.04.2011 at http://yacy.net
+//
+// $LastChangedDate$
+// $LastChangedRevision$
+// $LastChangedBy$
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program in the file lgpl21.txt
+// If not, see <http://www.gnu.org/licenses/>.
+//
+
+package net.yacy.http;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+
+import net.yacy.cora.protocol.Domains;
+import net.yacy.kelondro.data.meta.DigestURI;
++import net.yacy.search.Switchboard;
+
+import org.eclipse.jetty.security.SecurityHandler;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.Response;
+import org.eclipse.jetty.server.UserIdentity;
+
- import de.anomic.search.Switchboard;
-
+/**
+ * jetty security handler
+ * demands authentication for pages with _p. inside
+ */
+public class YaCySecurityHandler extends SecurityHandler {
+
+ @Override
+ protected boolean checkUserDataPermissions(String pathInContext, Request request,
+ Response response, Object constraintInfo) throws IOException {
+ // check the SecurityHandler code, denying here does not provide authentication
+ return true;
+ }
+
+ @Override
+ protected boolean checkWebResourcePermissions(String pathInContext, Request request,
+ Response response, Object constraintInfo, UserIdentity userIdentity) throws IOException {
+ // deny and request for authentication, if necessary
+ Boolean authMand = (Boolean)constraintInfo;
+ return !authMand || request.isUserInRole("admin");
+ }
+
+ @Override
+ protected boolean isAuthMandatory(Request base_request, Response base_response, Object constraintInfo) {
+ Boolean authMand = (Boolean)constraintInfo;
+ return authMand;
+ }
+
+ @Override
+ protected Object prepareConstraintInfo(String pathInContext, Request request) {
+ final Switchboard sb = Switchboard.getSwitchboard();
+ final boolean adminAccountForLocalhost = sb.getConfigBool("adminAccountForLocalhost", false);
+ final String adminAccountBase64MD5 = sb.getConfig(YaCyLegacyCredential.ADMIN_ACCOUNT_B64MD5, "");
+
+ String refererHost;
+ try {
+ refererHost = new DigestURI(request.getHeader("Referer")).getHost();
+ } catch (MalformedURLException e) {
+ refererHost = null;
+ }
+ final boolean accessFromLocalhost = Domains.isLocalhost(request.getRemoteHost()) && (refererHost == null || refererHost.length() == 0 || Domains.isLocalhost(refererHost));
+ final boolean grantedForLocalhost = adminAccountForLocalhost && accessFromLocalhost;
+ final boolean protectedPage = pathInContext.indexOf("_p.") > 0;
+ final boolean accountEmpty = adminAccountBase64MD5.length() == 0;
+ final boolean yacyBot = request.getHeader("User-Agent").startsWith("yacybot");
+
+ return protectedPage && ((!grantedForLocalhost && !accountEmpty) || yacyBot);
+ }
+
+}
diff --cc source/net/yacy/yacy.java
index de71661ac,ac62f5674..addcca206
--- a/source/net/yacy/yacy.java
+++ b/source/net/yacy/yacy.java
@@@ -47,17 -49,18 +49,19 @@@ import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream;
import net.yacy.cora.date.GenericFormatter;
- import net.yacy.cora.document.MultiProtocolURI;
+ import net.yacy.cora.document.ASCII;
import net.yacy.cora.document.UTF8;
+ import net.yacy.cora.lod.JenaTripleStore;
+ import net.yacy.cora.protocol.ClientIdentification;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.protocol.http.HTTPClient;
- import net.yacy.cora.storage.DynamicScore;
- import net.yacy.cora.storage.ScoreCluster;
+ import net.yacy.cora.sorting.Array;
+ import net.yacy.cora.sorting.OrderedScoreMap;
+ import net.yacy.cora.sorting.ScoreMap;
import net.yacy.gui.YaCyApp;
import net.yacy.gui.framework.Browser;
+import net.yacy.http.HttpServer;
import net.yacy.kelondro.blob.MapDataMining;
- //import net.yacy.kelondro.data.meta.DigestURI;
import net.yacy.kelondro.data.meta.URIMetadataRow;
import net.yacy.kelondro.data.word.Word;
import net.yacy.kelondro.data.word.WordReference;
@@@ -284,31 -304,49 +305,53 @@@ public final class yacy
// delete old release files
final int deleteOldDownloadsAfterDays = (int) sb.getConfigLong("update.deleteOld", 30);
yacyRelease.deleteOldDownloads(sb.releasePath, deleteOldDownloadsAfterDays );
-
+
// set user-agent
- final String userAgent = "yacy/" + Float.toString(version) + " (www.yacy.net; "
- + MultiProtocolURI.systemOST + ")";
- HTTPClient.setDefaultUserAgent(userAgent);
-
+ HTTPClient.setDefaultUserAgent(ClientIdentification.getUserAgent());
+
+ // initial fill of the triplestore
+ File triplestore = new File(sb.getConfig("triplestore", new File(dataHome, "DATA/TRIPLESTORE").getAbsolutePath()));
+ mkdirIfNeseccary(triplestore);
+ for (String s: triplestore.list()) {
+ if ((s.endsWith(".rdf") || s.endsWith(".nt")) && !s.equals("local.rdf") && !s.endsWith("_triplestore.rdf") && !s.startsWith("private_store_")) {
+ try {
+ JenaTripleStore.load(new File(triplestore, s).getAbsolutePath());
+ } catch (IOException e) {
+ Log.logException(e);
+ }
+ }
+ }
+ if (sb.getConfigBool("triplestore.persistent", false)) {
+ File local = new File(triplestore, "local.rdf");
+ if (local.exists()) {
+ try {
+ JenaTripleStore.load(local.getAbsolutePath());
+ } catch (IOException e) {
+ Log.logException(e);
+ }
+ }
+ }
+
// start main threads
- final String port = sb.getConfig("port", "8090");
+ final long port = sb.getConfigLong("port", 8090);
try {
- final HTTPDemon protocolHandler = new HTTPDemon(sb);
- final serverCore server = new serverCore(
- timeout /*control socket timeout in milliseconds*/,
- true /* block attacks (wrong protocol) */,
- protocolHandler /*command class*/,
- sb,
- 30000 /*command max length incl. GET args*/);
- server.setName("httpd:"+port);
- server.setPriority(Thread.MAX_PRIORITY);
- server.setObeyIntermission(false);
-
++
+ // start jetty http server
+ HttpServer httpServer = new HttpServer((int)port);
+ httpServer.start();
+ //final HTTPDemon protocolHandler = new HTTPDemon(sb);
+ //final serverCore server = new serverCore(
+ // timeout /*control socket timeout in milliseconds*/,
+ // true /* block attacks (wrong protocol) */,
+ // protocolHandler /*command class*/,
+ // sb,
+ // 30000 /*command max length incl. GET args*/);
+ //server.setName("httpd:"+port);
+ //server.setPriority(Thread.MAX_PRIORITY);
+ //server.setObeyIntermission(false);
+
// start the server
- sb.deployThread("10_httpd", "HTTPD Server/Proxy", "the HTTPD, used as web server and proxy", null, server, 0, 0, 0, 0);
+ //sb.deployThread("10_httpd", "HTTPD Server/Proxy", "the HTTPD, used as web server and proxy", null, server, 0, 0, 0, 0);
//server.start();
// open the browser window
@@@ -317,32 -355,17 +360,18 @@@
final String browserPopUpPage = sb.getConfig(SwitchboardConstants.BROWSER_POP_UP_PAGE, "ConfigBasic.html");
//boolean properPW = (sb.getConfig("adminAccount", "").length() == 0) && (sb.getConfig(httpd.ADMIN_ACCOUNT_B64MD5, "").length() > 0);
//if (!properPW) browserPopUpPage = "ConfigBasic.html";
- Browser.openBrowser((server.withSSL()?"https":"http") + "://localhost:" + serverCore.getPortNr(port) + "/" + browserPopUpPage);
++
+ Browser.openBrowser((false?"https":"http") + "://localhost:" + port + "/" + browserPopUpPage);
+ } catch (final Throwable e) {
+ // cannot open browser. This may be normal in headless environments
- //Log.logException(e);
++ //Log.logException(e);
}
-
- // unlock yacyTray browser popup
- Tray.lockBrowserPopup = false;
- // Copy the shipped locales into DATA, existing files are overwritten
- final File locale_work = sb.getDataPath("locale.work", "DATA/LOCALE/locales");
- final File locale_source = sb.getAppPath("locale.source", "locales");
- try{
- final File[] locale_source_files = locale_source.listFiles();
- mkdirsIfNeseccary(locale_work);
- File target;
- for (int i=0; i < locale_source_files.length; i++){
- target = new File(locale_work, locale_source_files[i].getName());
- if (locale_source_files[i].getName().endsWith(".lng")) {
- if (target.exists()) delete(target);
- FileUtils.copy(locale_source_files[i], target);
- }
- }
- Log.logInfo("STARTUP", "Copied the default locales to " + locale_work.toString());
- }catch(final NullPointerException e){
- Log.logSevere("STARTUP", "Nullpointer Exception while copying the default Locales");
- }
+ // enable browser popup, http server is ready now
+ sb.tray.setReady();
//regenerate Locales from Translationlist, if needed
+ final File locale_source = sb.getAppPath("locale.source", "locales");
final String lang = sb.getConfig("locale.language", "");
if (!lang.equals("") && !lang.equals("default")) { //locale is used
String currentRev = "";
@@@ -389,32 -412,16 +418,10 @@@
Log.logSevere("MAIN CONTROL LOOP", "PANIC: " + e.getMessage(),e);
}
// shut down
- if (RowCollection.sortingthreadexecutor != null) RowCollection.sortingthreadexecutor.shutdown();
+ Array.terminate();
Log.logConfig("SHUTDOWN", "caught termination signal");
- //server.terminate(false);
- //server.interrupt();
- //server.close();
- server.terminate(false);
- server.interrupt();
- server.close();
-
- // idle until the processes are down
- if (server.isAlive()) {
- server.interrupt();
- }
+ httpServer.stop();
- /*
- if (server.isAlive()) try {
- // TODO only send request, don't read response (cause server is already down resulting in error)
- final DigestURI u = new DigestURI((server.withSSL()?"https":"http")+"://localhost:" + serverCore.getPortNr(port), null);
- Client.wget(u.toString(), null, 10000); // kick server
- Log.logConfig("SHUTDOWN", "sent termination signal to server socket");
- } catch (final IOException ee) {
- Log.logConfig("SHUTDOWN", "termination signal to server socket missed (server shutdown, ok)");
- }
- */
- // Client.closeAllConnections();
- // MultiThreadedHttpConnectionManager.shutdownAll();
-
- // idle until the processes are down
- //if (server.isAlive()) {
- //Thread.sleep(2000); // wait a while
- // server.interrupt();
- // MultiThreadedHttpConnectionManager.shutdownAll();
- //}
- // MultiThreadedHttpConnectionManager.shutdownAll();
++
Log.logConfig("SHUTDOWN", "server has terminated");
sb.close();
} catch (final Exception e) {