Skip to content

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

remove references to 10_http thread (legacy http server) and add needed get/set function to jetty http server wrapper

reger127adbf5cf81
diff --git a/htroot/ConfigBasic.java b/htroot/ConfigBasic.java
index ef545eb13..efa74a8be 100644
--- a/htroot/ConfigBasic.java
+++ b/htroot/ConfigBasic.java
@@ -38,6 +38,7 @@ import net.yacy.cora.protocol.HeaderFramework;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.data.Translator;
import net.yacy.data.WorkTables;
+import net.yacy.http.HttpServer;
import net.yacy.kelondro.workflow.InstantBusyThread;
import net.yacy.peers.Seed;
import net.yacy.search.Switchboard;
@@ -131,7 +132,7 @@ public class ConfigBasic {
final boolean reconnect;
if (!(env.getConfigLong("port", port) == port) || env.getConfigBool("server.https", false) != ssl) {
// validate port
- final serverCore theServerCore = (serverCore) env.getThread("10_httpd");
+ final HttpServer theServerCore = env.getHttpServer();
env.setConfig("port", port);
env.setConfig("server.https", ssl);
@@ -157,7 +158,7 @@ public class ConfigBasic {
prop.put("nextStep_host", host);
prop.put("reconnect_port", port);
prop.put("nextStep_port", port);
- prop.put("reconnect_sslSupport", theServerCore.withSSL() ? "1" : "0");
+ prop.put("reconnect_sslSupport", theServerCore.withSSL() ? "1" : "0");
prop.put("nextStep_sslSupport", theServerCore.withSSL() ? "1" : "0");
// generate new shortcut (used for Windows)
diff --git a/htroot/PerformanceQueues_p.java b/htroot/PerformanceQueues_p.java
index 3f8bb4791..a35ec8921 100644
--- a/htroot/PerformanceQueues_p.java
+++ b/htroot/PerformanceQueues_p.java
@@ -31,6 +31,7 @@ import java.util.Map;
import net.yacy.cora.protocol.HeaderFramework;
import net.yacy.cora.protocol.RequestHeader;
+import net.yacy.http.HttpServer;
import net.yacy.kelondro.data.word.WordReference;
import net.yacy.kelondro.rwi.IndexCell;
import net.yacy.kelondro.util.FileUtils;
@@ -266,14 +267,14 @@ public class PerformanceQueues_p {
/*
* configuring the http pool
*/
- final WorkflowThread httpd = sb.getThread("10_httpd");
+ final HttpServer httpd = sb.getHttpServer();
try {
maxBusy = post.getInt("httpd Session Pool_maxActive", 8);
} catch (final NumberFormatException e) {
maxBusy = 8;
}
- ((serverCore)httpd).setMaxSessionCount(maxBusy);
+ (httpd).setMaxSessionCount(maxBusy);
// storing the new values into configfile
sb.setConfig("httpdMaxBusySessions",maxBusy);
@@ -310,10 +311,10 @@ public class PerformanceQueues_p {
prop.put("pool_0_maxActive", sb.getConfigLong("crawler.MaxActiveThreads", 0));
prop.put("pool_0_numActive",sb.crawlQueues.workerSize());
- final WorkflowThread httpd = sb.getThread("10_httpd");
+ final HttpServer httpd = sb.getHttpServer();
prop.put("pool_1_name", "httpd Session Pool");
- prop.put("pool_1_maxActive", ((serverCore)httpd).getMaxSessionCount());
- prop.put("pool_1_numActive", ((serverCore)httpd).getJobCount());
+ prop.put("pool_1_maxActive", httpd.getMaxSessionCount());
+ prop.put("pool_1_numActive", httpd.getJobCount());
prop.put("pool", "2");
diff --git a/htroot/SettingsAck_p.java b/htroot/SettingsAck_p.java
index 46ba26bb2..426e35fa0 100644
--- a/htroot/SettingsAck_p.java
+++ b/htroot/SettingsAck_p.java
@@ -40,6 +40,7 @@ import net.yacy.cora.order.Base64Order;
import net.yacy.cora.order.Digest;
import net.yacy.cora.protocol.Domains;
import net.yacy.cora.protocol.RequestHeader;
+import net.yacy.http.HttpServer;
import net.yacy.kelondro.util.Formatter;
import net.yacy.peers.Network;
import net.yacy.peers.Seed;
@@ -108,7 +109,7 @@ public class SettingsAck_p {
prop.putHTML("info_port", port);
if (!env.getConfig("port", port).equals(port)) {
// validation port
- final serverCore theServerCore = (serverCore) env.getThread("10_httpd");
+ final HttpServer theServerCore = env.getHttpServer();
try {
final InetSocketAddress theNewAddress = theServerCore.generateSocketAddress(port);
final String hostName = Domains.getHostName(theNewAddress.getAddress());
diff --git a/htroot/Status.java b/htroot/Status.java
index 88864d757..faf84d0f1 100644
--- a/htroot/Status.java
+++ b/htroot/Status.java
@@ -33,6 +33,7 @@ import java.util.Date;
import net.yacy.cora.protocol.Domains;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.util.Memory;
+import net.yacy.http.HttpServer;
import net.yacy.kelondro.io.ByteCount;
import net.yacy.kelondro.util.Formatter;
import net.yacy.kelondro.util.MemoryControl;
@@ -326,11 +327,11 @@ public class Status
prop.put("trafficCrawler", Formatter.bytesToString(ByteCount.getAccountCount(ByteCount.CRAWLER)));
// connection information
- final serverCore httpd = (serverCore) sb.getThread("10_httpd");
-
- //prop.putNum("connectionsActive", httpd.getJobCount());
- //prop.putNum("connectionsMax", httpd.getMaxSessionCount());
-
+ final HttpServer httpd = sb.getHttpServer();
+
+ prop.putNum("connectionsActive", httpd.getJobCount());
+ prop.putNum("connectionsMax", httpd.getMaxSessionCount());
+
// Queue information
final int loaderJobCount = sb.crawlQueues.workerSize();
final int loaderMaxCount = sb.getConfigInt(SwitchboardConstants.CRAWLER_THREADS_ACTIVE_MAX, 10);
diff --git a/source/net/yacy/http/HttpServer.java b/source/net/yacy/http/HttpServer.java
index 7ac9df86c..d4c5be2a2 100644
--- a/source/net/yacy/http/HttpServer.java
+++ b/source/net/yacy/http/HttpServer.java
@@ -24,6 +24,11 @@
package net.yacy.http;
+import java.net.InetSocketAddress;
+import java.net.SocketException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import net.yacy.cora.util.ConcurrentLog;
import net.yacy.search.Switchboard;
import org.eclipse.jetty.server.Handler;
@@ -34,12 +39,11 @@ import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.server.nio.SelectChannelConnector;
-
/**
* class to embedded jetty http server into YaCy
*/
public class HttpServer {
-
+
private Server server = new Server();
/**
@@ -80,29 +84,65 @@ public class HttpServer {
server.setHandler(context);
}
-
- /**
- * start http server
- */
- public void start() throws Exception {
+
+ /**
+ * start http server
+ */
+ public void start() throws Exception {
server.start();
- }
-
- /**
- * stop http server and wait for it
- */
- public void stop() throws Exception {
- server.stop();
+ }
+
+ /**
+ * 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();
- }
+ public void setMaxSessionCount(int maxBusy) {
+ // TODO:
+ }
+
+ public boolean withSSL() {
+ return false; // TODO:
+ }
+ public void reconnect(int milsec) {
+ try {
+ Thread.sleep(milsec);
+ } catch (final InterruptedException e) {
+ ConcurrentLog.logException(e);
+ } catch (final Exception e) {
+ ConcurrentLog.logException(e);
+ }
+ try {
+ server.stop();
+ server.join();
+ server.start();
+ } catch (Exception ex) {
+ ConcurrentLog.logException(ex);
+ }
+ }
+
+ public InetSocketAddress generateSocketAddress(String port) throws SocketException {
+ return null; // TODO:
+ }
+
+ public int getMaxSessionCount() {
+ return server.getThreadPool().getThreads();
+ }
+
+ public int getJobCount() {
+ return getMaxSessionCount()-server.getThreadPool().getIdleThreads(); // TODO:
+ }
+
+ /**
+ * just for testing and debugging
+ */
+ public static void main(String[] args) throws Exception {
+ HttpServer server = new HttpServer(8090);
+ server.start();
+ server.stop();
+ }
}
diff --git a/source/net/yacy/server/serverSwitch.java b/source/net/yacy/server/serverSwitch.java
index 59f0cb71a..67efd230a 100644
--- a/source/net/yacy/server/serverSwitch.java
+++ b/source/net/yacy/server/serverSwitch.java
@@ -47,6 +47,7 @@ import net.yacy.cora.protocol.HeaderFramework;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.protocol.http.HTTPClient;
import net.yacy.cora.util.ConcurrentLog;
+import net.yacy.http.HttpServer;
import net.yacy.kelondro.util.FileUtils;
import net.yacy.kelondro.workflow.BusyThread;
import net.yacy.kelondro.workflow.WorkflowThread;
@@ -69,7 +70,8 @@ public class serverSwitch
private final ConcurrentMap<InetAddress, String> authorization;
private final NavigableMap<String, BusyThread> workerThreads;
private final serverAccessTracker accessTracker;
-
+ private HttpServer httpserver;
+
public serverSwitch(
final File dataPath,
final File appPath,
@@ -639,5 +641,15 @@ public class serverSwitch
pwGenerator.nextBytes(bytes);
return Digest.encodeMD5Hex(bytes);
}
+ /**
+ * set/remember jetty server
+ * @param jettyserver
+ */
+ public void setHttpServer(HttpServer jettyserver) {
+ this.httpserver = jettyserver;
+ }
+ public HttpServer getHttpServer() {
+ return httpserver;
+ }
}
diff --git a/source/net/yacy/yacy.java b/source/net/yacy/yacy.java
index a7564762b..db77f78ce 100644
--- a/source/net/yacy/yacy.java
+++ b/source/net/yacy/yacy.java
@@ -327,7 +327,7 @@ public final class yacy {
}
// start main threads
- final long port = sb.getConfigLong("port", 8090);
+ final int port = sb.getConfigInt("port", 8090);
try {
// start jetty http server
@@ -346,6 +346,7 @@ public final class yacy {
// 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.setHttpServer(httpServer);
//server.start();
// open the browser window