Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
(no author) committed May 31, 2007
1 parent 0610285 commit 1efe607
Show file tree
Hide file tree
Showing 5 changed files with 246 additions and 55 deletions.
4 changes: 2 additions & 2 deletions htroot/SearchStatistics_p.html
Expand Up @@ -63,7 +63,7 @@ <h2>Search Statistics: Local Searche Tracker</h2>
<tr class="TableCell#(dark)#Light::Dark#(/dark)#">
<td>#[host]#</td>
<td>#[count]#</td>
<td>#[dates]#</td>
<td>#{dates}##[date]# #{/dates}#</td>
</tr>
#{/list}#
</table>
Expand Down Expand Up @@ -111,7 +111,7 @@ <h2>Search Statistics: Remote Searche Tracker</h2>
<td>#[host]#</td>
<td>#[peername]#</td>
<td>#[count]#</td>
<td>#[dates]#</td>
<td>#{dates}##[date]# #{/dates}#</td>
</tr>
#{/list}#
</table>
Expand Down
15 changes: 11 additions & 4 deletions htroot/SearchStatistics_p.java
Expand Up @@ -67,6 +67,7 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
prop.put("page_list_" + entCount + "_dark", ((dark) ? 1 : 0) ); dark =! dark;
prop.put("page_list_" + entCount + "_host", (String) searchProfile.get("host"));
prop.put("page_list_" + entCount + "_date", yacyCore.universalDateShortString(new Date(trackerHandle.longValue())));
prop.put("page_list_" + entCount + "_timestamp", Long.toString(trackerHandle.longValue()));
if (page == 1) {
// local search
prop.put("page_list_" + entCount + "_offset", ((Integer) searchProfile.get("offset")).toString());
Expand All @@ -87,27 +88,33 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
}
if ((page == 2) || (page == 4)) {
Iterator i = (page == 2) ? switchboard.localSearchTracker.entrySet().iterator() : switchboard.remoteSearchTracker.entrySet().iterator();
String host, handlestring;
String host;
TreeSet handles;
int entCount = 0;
Map.Entry entry;
while ((entCount < maxCount) && (i.hasNext())) {
entry = (Map.Entry) i.next();
host = (String) entry.getKey();
handles = (TreeSet) entry.getValue();
handlestring = "";

int dateCount = 0;
Iterator ii = handles.iterator();
while (ii.hasNext()) {
handlestring += yacyCore.universalDateShortString(new Date(((Long) ii.next()).longValue())) + " ";
Long timestamp = (Long) ii.next();
prop.put("page_list_" + entCount + "_dates_" + dateCount + "_date", yacyCore.universalDateShortString(new Date(timestamp.longValue())));
prop.put("page_list_" + entCount + "_dates_" + dateCount + "_timestamp", timestamp.toString());
dateCount++;
}
prop.put("page_list_" + entCount + "_dates", dateCount);

prop.put("page_list_" + entCount + "_dark", ((dark) ? 1 : 0) ); dark =! dark;
prop.put("page_list_" + entCount + "_host", host);
if (page == 4) {
yacySeed remotepeer = yacyCore.seedDB.lookupByIP(natLib.getInetAddress(host), true, true, true);
prop.put("page_list_" + entCount + "_peername", (remotepeer == null) ? "UNKNOWN" : remotepeer.getName());
}
prop.put("page_list_" + entCount + "_count", new Integer(handles.size()).toString());
prop.put("page_list_" + entCount + "_dates", handlestring);

// next
entCount++;
}
Expand Down
42 changes: 42 additions & 0 deletions htroot/SearchStatistics_p.xml
@@ -0,0 +1,42 @@
<?xml version="1.0"?>
<SearchStatistics>
#(page)#<!-- 0: info text -->
::<!-- 1: Search Statistics: Local Searches -->
<localSearchLog>#{list}#
<host>#[host]#</host>
<date timestamp="#[timestamp]#">#[date]#</date>
<offset>#[offset]#</offset>
<querycount>#[querycount]#</querycount>
<resultcount>#[resultcount]#</resultcount>
<querytime>#[querytime]#</querytime>
<resulttime>#[resulttime]#</resulttime>
<querystring>#[querystring]#</querystring>
#{/list}#</localSearchLog>

::<!-- 2: Search Statistics: Local Search Tracker -->
<localSearchTracker>#{list}#
<host>#[host]#</host>
<count>#[count]#</count>
<dates>#{dates}#
<date timestamp="#[timestamp]#">#[date]#</date>
#{/dates}#</dates>
#{/list}#</localSearchTracker>

::<!-- 3: Search Statistics: Remote Searches -->
<remoteSearchLog>#{list}#
<host>#[host]#</host>
<peername>#[peername]#</peername>
<date timestamp="#[timestamp]#">#[date]#</date>
<querycount>#[querycount]#</>
<resultcount>#[resultcount]#</resultcount>
<querytime>#[querytime]#</querytime>
<resulttime>#[resulttime]#</resulttime>
<queryhashes>#[queryhashes]#</queryhashes>
#{/list}#</remoteSearchLog>

::<!-- 4: Search Statistics: Remote Search Tracker -->
<remoteSearchTracker>#{list}#
#{/list}#</remoteSearchTracker>

#(/page)#
</SearchStatistics>
40 changes: 40 additions & 0 deletions source/de/anomic/soap/services/SearchService.java
Expand Up @@ -70,7 +70,15 @@ public class SearchService extends AbstractService
private static final String TEMPLATE_URLINFO = "ViewFile.soap";
private static final String TEMPLATE_SNIPPET = "xml/snippet.xml";
private static final String TEMPLATE_OPENSEARCH = "opensearchdescription.xml";
private static final String TEMPLATE_SEARCHSTATS = "SearchStatistics_p.html";

/* =====================================================================
* Constants needed to get search statistic info
* ===================================================================== */
private static final int SEARCHSTATS_LOCAL_SEARCH_LOG = 1;
private static final int SEARCHSTATS_LOCAL_SEARCH_TRACKER = 2;
private static final int SEARCHSTATS_REMOTE_SEARCH_LOG = 3;
private static final int SEARCHSTATS_REMOTE_SEARCH_TRACKER = 4;

/**
* Constructor of this class
Expand Down Expand Up @@ -302,5 +310,37 @@ public Document getOpenSearchDescription() throws Exception {
// sending back the result to the client
return this.convertContentToXML(result);
}

private Document getSearchStatData(int page) throws Exception {
if (page < 1 || page > 4) throw new IllegalArgumentException("Illegal page number.");

// extracting the message context
extractMessageContext(AUTHENTICATION_NEEDED);

serverObjects post = new serverObjects();
post.put("page", Integer.toString(page));

// generating the template containing the network status information
byte[] result = this.serverContext.writeTemplate(TEMPLATE_SEARCHSTATS, post, this.requestHeader);

// sending back the result to the client
return this.convertContentToXML(result);
}

public Document getLocalSearchLog() throws Exception {
return this.getSearchStatData(SEARCHSTATS_LOCAL_SEARCH_LOG);
}

public Document getLocalSearchTracker() throws Exception {
return this.getSearchStatData(SEARCHSTATS_LOCAL_SEARCH_TRACKER);
}

public Document getRemoteSearchLog() throws Exception {
return this.getSearchStatData(SEARCHSTATS_REMOTE_SEARCH_LOG);
}

public Document getRemoteSearchTracker() throws Exception {
return this.getSearchStatData(SEARCHSTATS_REMOTE_SEARCH_TRACKER);
}

}

0 comments on commit 1efe607

Please sign in to comment.