Skip to content

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

Added a new steering servlet that can be used to repeat actions that had been made on the yacy interface. This can be used to: - start again a previously started crawl - submit settings (again). This option will be used to transmit all settings of one peer to another peer if the remote-peer steering function is ready This steering framework will also be used for a 'schedule-everything' which will also include a new scheduler for crawling.

orbiter8a76f38d269b
diff --git a/htroot/Table_API_p.html b/htroot/Table_API_p.html
new file mode 100644
index 000000000..2835aa766
--- /dev/null
+++ b/htroot/Table_API_p.html
@@ -0,0 +1,70 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>YaCy '#[clientname]#': Peer Steering</title>
+ #(showtable)#::
+ <link rel="alternate" type="application/xml" title="Tables" href="Tables.rss?table=#[table]#" />
+ #(/showtable)#
+ #%env/templates/metas.template%#
+ </head>
+ <body id="Tables">
+ #%env/templates/header.template%#
+
+ <h2>Steering of API Actions</h2>
+ <p>This table shows actions that had been issued on the YaCy interface
+ to change the configuration or to request crawl actions.
+ These recorded actions can be used to repeat specific actions and to send them
+ to a scheduler for a periodic execution.
+ </p>
+ #(showtable)#::
+ <form action="Table_API_p.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
+ <fieldset>
+ <legend><label for="table">Recorded Actions</label></legend>
+ <table border="0" cellpadding="2" cellspacing="1">
+ <tr class="TableHeader" valign="bottom">
+ <td>&nbsp;</td>
+ <td>Date</td>
+ <td>Type</td>
+ <td>Comment</td>
+ <td>URL</td>
+ </tr>
+ #{list}#
+ <tr class="TableCell#(dark)#Light::Dark::Summary#(/dark)#">
+ <td align="left"><input type="checkbox" name="mark_#[pk]#" /></td>
+ <td>#[date]#</td>
+ <td>#[type]#</td>
+ <td>#[comment]#</td>
+ <td>#[url]#</td>
+ </tr>
+ #{/list}#
+ </table>
+ <p>
+ <input type="hidden" name="table" value="#[table]#" />
+ <input type="submit" name="execrows" value="Execute Selected Actions" />
+ <input type="submit" name="deleterows" value="Delete Selected Actions" />
+ </p>
+ </fieldset>
+ </form>
+ #(/showtable)#
+ #(showexec)#::
+ <form action="#">
+ <fieldset>
+ <legend><label for="table">Result of API execution</label></legend>
+ <table border="0" cellpadding="2" cellspacing="1">
+ <tr class="TableHeader" valign="bottom">
+ <td>Status</td>
+ <td>URL</td>
+ </tr>
+ #{list}#
+ <tr class="TableCell#(dark)#Light::Dark::Summary#(/dark)#">
+ <td>#[status]#</td>
+ <td>#[url]#</td>
+ </tr>
+ #{/list}#
+ </table>
+ </fieldset>
+ </form>
+ #(/showexec)#
+ #%env/templates/footer.template%#
+ </body>
+</html>
diff --git a/htroot/Table_API_p.java b/htroot/Table_API_p.java
new file mode 100644
index 000000000..42f6f843d
--- /dev/null
+++ b/htroot/Table_API_p.java
@@ -0,0 +1,115 @@
+// Table_API_p.java
+// -----------------------
+// (C) 2010 by Michael Peter Christen; [email protected]
+// first published 01.02.2010 in Frankfurt, Germany on http://yacy.net
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program 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 General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import net.yacy.kelondro.logging.Log;
+
+import de.anomic.data.Tables;
+import de.anomic.http.client.Client;
+import de.anomic.http.server.RequestHeader;
+import de.anomic.http.server.ResponseContainer;
+import de.anomic.search.Switchboard;
+import de.anomic.server.serverObjects;
+import de.anomic.server.serverSwitch;
+
+public class Table_API_p {
+
+ public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
+ final Switchboard sb = (Switchboard) env;
+ final serverObjects prop = new serverObjects();
+
+ if (post != null && post.get("deleterows", "").length() > 0) {
+ for (Map.Entry<String, String> entry: post.entrySet()) {
+ if (entry.getKey().startsWith("mark_") && entry.getValue().equals("on")) {
+ sb.tables.delete(Tables.API_TABLENAME, entry.getKey().substring(5).getBytes());
+ }
+ }
+ }
+
+ prop.put("showexec", 0);
+ prop.put("showtable", 0);
+
+ if (post != null && post.get("execrows", "").length() > 0) {
+ final RequestHeader reqHeader = new RequestHeader();
+ final Client client = new Client(120000, reqHeader);
+ ResponseContainer result;
+ LinkedHashMap<String, Integer> l = new LinkedHashMap<String, Integer>();
+ for (Map.Entry<String, String> entry: post.entrySet()) {
+ if (entry.getKey().startsWith("mark_") && entry.getValue().equals("on")) {
+ Map<String, byte[]> map = sb.tables.select(Tables.API_TABLENAME, entry.getKey().substring(5).getBytes());
+ String url = "http://localhost:" + sb.getConfig("port", "8080") + new String(map.get(Tables.API_COL_URL));
+ try {
+ result = client.GET(url);
+ l.put(url, result.getStatusCode());
+ } catch (IOException e) {
+ Log.logException(e);
+ }
+ }
+ }
+ // construct result table
+ prop.put("showexec", 1);
+
+ final Iterator<Map.Entry<String, Integer>> resultIterator = l.entrySet().iterator();
+ Map.Entry<String, Integer> record;
+ int count = 0;
+ boolean dark = true;
+ while (resultIterator.hasNext()) {
+ record = resultIterator.next();
+ if (record == null) continue;
+ prop.put("showexec_list_" + count + "_dark", ((dark) ? 1 : 0) ); dark=!dark;
+ prop.put("showexec_list_" + count + "_status", record.getValue());
+ prop.put("showexec_list_" + count + "_url", record.getKey());
+ count++;
+ }
+ prop.put("showexec_list", count);
+ }
+
+ // generate table
+ prop.put("showtable", 1);
+
+ // insert rows
+ final int maxCount = Math.min(1000, sb.tables.size(Tables.API_TABLENAME));
+ final Iterator<Map.Entry<byte[], Map<String, byte[]>>> mapIterator = sb.tables.iterator(Tables.API_TABLENAME);
+ Map.Entry<byte[], Map<String, byte[]>> record;
+ Map<String, byte[]> map;
+ int count = 0;
+ boolean dark = true;
+ while ((mapIterator.hasNext()) && (count < maxCount)) {
+ record = mapIterator.next();
+ if (record == null) continue;
+ map = record.getValue();
+ prop.put("showtable_list_" + count + "_dark", ((dark) ? 1 : 0) ); dark=!dark;
+ prop.put("showtable_list_" + count + "_pk", new String(record.getKey()));
+ prop.put("showtable_list_" + count + "_date", map.get(Tables.API_COL_DATE));
+ prop.put("showtable_list_" + count + "_type", map.get(Tables.API_COL_TYPE));
+ prop.put("showtable_list_" + count + "_comment", map.get(Tables.API_COL_COMMENT));
+ prop.put("showtable_list_" + count + "_url", "http://" + sb.myPublicIP() + ":" + sb.getConfig("port", "8080") + new String(map.get(Tables.API_COL_URL)));
+ count++;
+ }
+ prop.put("showtable_list", count);
+
+ // return rewrite properties
+ return prop;
+ }
+
+}
diff --git a/htroot/env/templates/header.template b/htroot/env/templates/header.template
index 6564c8869..61ef14855 100644
--- a/htroot/env/templates/header.template
+++ b/htroot/env/templates/header.template
@@ -82,14 +82,15 @@
<li><a href="/WatchWebStructure_p.html?host=auto&amp;depth=2&amp;time=1000" class="MenuItemLink lock">Web Visualization</a></li>
<li><a href="/AccessTracker_p.html" class="MenuItemLink lock">Access Tracker</a></li>
<li><a href="/ViewLog_p.html" class="MenuItemLink lock">Server Log</a></li>
+ <li><a href="/Messages_p.html" class="MenuItemLink lock">Messages<img src="/notifier.gif" alt="New Messages" /></a></li>
+ <li><a href="/terminal_p.html" accesskey="t" class="MenuItemLink lock">Terminal</a></li>
</ul>
</li>
<li class="menugroup" id="menugroupPeerControl">
<h3>Peer Control</h3>
<ul class="menu">
<li><a href="/Status.html" class="MenuItemLink">Admin Console</a></li>
- <li><a href="/terminal_p.html" accesskey="t" class="MenuItemLink lock">Terminal</a></li>
- <li><a href="/Messages_p.html" class="MenuItemLink lock">Messages <img src="/notifier.gif" alt="New Messages" /></a></li>
+ <li><a href="/Table_API_p.html" class="MenuItemLink">Steering</a></li>
<li><a href="/Steering.html?restart=" class="MenuItemLink lock" onclick="return confirm('Confirm Restart')">Re-Start</a></li>
<li><a href="/Steering.html?shutdown=" class="MenuItemLink lock" onclick="return confirm('Confirm Shutdown')">Shutdown</a></li>
</ul>
diff --git a/source/de/anomic/data/Tables.java b/source/de/anomic/data/Tables.java
index 071b5ecbe..8fc8a2052 100644
--- a/source/de/anomic/data/Tables.java
+++ b/source/de/anomic/data/Tables.java
@@ -18,9 +18,16 @@ import de.anomic.server.serverObjects;
public class Tables {
+ public final static String API_TABLENAME = "api";
+ public final static String API_TYPE_STEERING = "steering";
public final static String API_TYPE_CONFIGURATION = "configuration";
public final static String API_TYPE_CRAWLER = "crawler";
+ public final static String API_COL_TYPE = "type";
+ public final static String API_COL_COMMENT = "comment";
+ public final static String API_COL_DATE = "date";
+ public final static String API_COL_URL = "url";
+
private BEncodedHeapArray tables;
public Tables(File workPath) {
@@ -126,11 +133,11 @@ public class Tables {
String apiurl = /*"http://localhost:" + getConfig("port", "8080") +*/ "/" + servletName + "?" + post.toString();
try {
this.tables.insert(
- "api",
- "type", type.getBytes(),
- "comment", comment.getBytes(),
- "date", DateFormatter.formatShortMilliSecond(new Date()).getBytes(),
- "url", apiurl.getBytes()
+ API_TABLENAME,
+ API_COL_TYPE, type.getBytes(),
+ API_COL_COMMENT, comment.getBytes(),
+ API_COL_DATE, DateFormatter.formatShortMilliSecond(new Date()).getBytes(),
+ API_COL_URL, apiurl.getBytes()
);
} catch (RowSpaceExceededException e2) {
Log.logException(e2);