/////////// // // main > Basic > Status // /////////// bool sendPageBasicStatus ( TcpSocket *socket , HttpRequest *hr ) { char buf [ 128000 ]; SafeBuf sb(buf,128000); sb.reset(); char format = hr->getReplyFormat(); // true = usedefault coll? CollectionRec *cr = g_collectiondb.getRec ( hr , true ); if ( ! cr ) { g_httpServer.sendErrorReply(socket,500,"invalid collection"); return true; } if ( format == FORMAT_JSON || format == FORMAT_XML) { // this is in PageCrawlBot.cpp printCrawlDetails2 ( &sb , cr , format ); char *ct = "text/xml"; if ( format == FORMAT_JSON ) ct = "application/json"; return g_httpServer.sendDynamicPage (socket, sb.getBufStart(), sb.length(), 0, // cachetime false,//POSTReply , ct); } // print standard header if ( format == FORMAT_HTML ) // this prints the <form tag as well g_pages.printAdminTop ( &sb , socket , hr ); // table to split between widget and stats in left and right panes if ( format == FORMAT_HTML ) { sb.safePrintf("<TABLE id=pane>" "<TR><TD valign=top>"); } int32_t savedLen1, savedLen2; // // widget // // put the widget in here, just sort results by spidered date // // the scripts do "infinite" scrolling both up and down. // but if you are at the top then new results will load above // you and we try to maintain your current visual state even though // the scrollbar position will change. // if ( format == FORMAT_HTML ) { // save position so we can output the widget code // so user can embed it into their own web page savedLen1 = sb.length(); printScrollingWidget ( &sb , cr ); savedLen2 = sb.length(); } // the right table pane is the crawl stats if ( format == FORMAT_HTML ) { sb.safePrintf("</TD><TD valign=top>"); } // // show stats // if ( format == FORMAT_HTML ) { char *seedStr = cr->m_diffbotSeeds.getBufStart(); if ( ! seedStr ) seedStr = ""; SafeBuf tmp; int32_t crawlStatus = -1; getSpiderStatusMsg ( cr , &tmp , &crawlStatus ); CrawlInfo *ci = &cr->m_localCrawlInfo; int32_t sentAlert = (int32_t)ci->m_sentCrawlDoneAlert; if ( sentAlert ) sentAlert = 1; //sb.safePrintf( // "<form method=get action=/crawlbot>" // "%s" // , sb.getBufStart() // hidden input token/name/.. // ); char *hurts = "No"; if ( cr->m_globalCrawlInfo.m_hasUrlsReadyToSpider ) hurts = "Yes"; sb.safePrintf(//"<TABLE border=0>" //"<TR><TD valign=top>" "<table id=stats border=0 cellpadding=5>" "<tr>" "<td><b>Crawl Status Code:</td>" "<td>%" PRId32"</td>" "</tr>" "<tr>" "<td><b>Crawl Status Msg:</td>" "<td>%s</td>" "</tr>" //"<tr>" //"<td><b>Rounds Completed:</td>" //"<td>%" PRId32"</td>" //"</tr>" "<tr>" "<td><b>Has Urls Ready to Spider:</td>" "<td>%s</td>" "</tr>" // this will have to be in crawlinfo too! //"<tr>" //"<td><b>pages indexed</b>" //"<td>%" PRId64"</td>" //"</tr>" "<tr>" "<td><b><nobr>URLs Harvested</b> " "(may include dups)</nobr></td>" "<td>%" PRId64"</td>" "</tr>" //"<tr>" //"<td><b>URLs Examined</b></td>" //"<td>%" PRId64"</td>" //"</tr>" "<tr>" "<td><b>Page Crawl Attempts</b></td>" "<td>%" PRId64"</td>" "</tr>" "<tr>" "<td><b>Page Crawl Successes</b></td>" "<td>%" PRId64"</td>" "</tr>" , crawlStatus , tmp.getBufStart() //, cr->m_spiderRoundNum //, cr->m_globalCrawlInfo.m_hasUrlsReadyToSpider , hurts , cr->m_globalCrawlInfo.m_urlsHarvested //, cr->m_globalCrawlInfo.m_urlsConsidered , cr->m_globalCrawlInfo.m_pageDownloadAttempts , cr->m_globalCrawlInfo.m_pageDownloadSuccesses ); // // begin status code breakdown // for ( int32_t i = 0 ; i < 65536 ; i++ ) { if ( g_stats.m_allErrorsNew[i] == 0 && g_stats.m_allErrorsOld[i] == 0 ) continue; sb.safePrintf ( "<tr>" "<td><b> <a href=/search?c=%s&q=" "gbstatusmsg%%3A" "%%22" , cr->m_coll ); sb.urlEncode(mstrerror(i)); sb.safePrintf ("%%22>" "%s" "</a>" "</b></td>" "<td>%" PRId64"</td>" "</tr>\n" , mstrerror(i), g_stats.m_allErrorsNew[i] + g_stats.m_allErrorsOld[i] ); } // // end status code breakdown // char tmp3[64]; struct tm *timeStruct; time_t tt = (time_t)cr->m_diffbotCrawlStartTime; timeStruct = localtime(&tt); // Jan 01 1970 at 10:30:00 strftime ( tmp3,64 , "%b %d %Y at %H:%M:%S",timeStruct); sb.safePrintf("<tr><td><b>Collection Created</b></td>" "<td>%s (local time)</td></tr>",tmp3); // print link to embed the code in their own site SafeBuf embed; embed.htmlEncode(sb.getBufStart()+savedLen1, savedLen2-savedLen1, false); // encodePoundSign #? // convert all ''s to "'s for php's echo ''; cmd embed.replaceChar('\'','\"'); sb.safePrintf("<tr>" "<td valign=top>" "<a onclick=\"" "var dd=document.getElementById('hcode');" "if ( dd.style.display=='none' ) " "dd.style.display=''; " "else " "dd.style.display='none';" "\" style=color:blue;>" "<u>" "show Widget HTML code" "</u>" "</a>" "</td><td>" "<div id=hcode style=display:none;" "max-width:800px;>" "%s" "</div>" "</td></tr>" , embed.getBufStart() ); sb.safePrintf("<tr>" "<td valign=top>" "<a onclick=\"" "var dd=document.getElementById('pcode');" "if ( dd.style.display=='none' ) " "dd.style.display=''; " "else " "dd.style.display='none';" "\" style=color:blue;>" "<u>" "show Widget PHP code" "</u>" "</a>" "</td>" "<td>" "<div id=pcode style=display:none;" "max-width:800px;>" "<i>" "echo '" "%s" "';" "</i>" "</div>" "</td></tr>" , embed.getBufStart() ); sb.safePrintf("</table>\n\n"); } // end the right table pane if ( format == FORMAT_HTML ) { sb.safePrintf("</TD></TR></TABLE>"); } //if ( format != FORMAT_JSON ) // // wrap up the form, print a submit button // g_pages.printAdminBottom ( &sb ); return g_httpServer.sendDynamicPage (socket, sb.getBufStart(), sb.length(), 0); // cachetime }
void processReply ( char *reply , long replyLen ) { // store our current reply SafeBuf fb2; fb2.safeMemcpy(reply,replyLen ); fb2.nullTerm(); // log that we got the reply log("qa: got reply(len=%li)(errno=%s)=%s", replyLen,mstrerror(g_errno),reply); char *content = NULL; long contentLen = 0; // get mime if ( reply ) { HttpMime mime; mime.set ( reply, replyLen , NULL ); // only hash content since mime has a timestamp in it content = mime.getContent(); contentLen = mime.getContentLen(); if ( content && contentLen>0 && content[contentLen] ) { char *xx=NULL;*xx=0; } } if ( ! content ) { content = ""; contentLen = 0; } s_content = content; // take out <responseTimeMS> markOut ( content , "<currentTimeUTC>"); markOut ( content , "<responseTimeMS>"); // until i figure this one out, take it out markOut ( content , "<docsInCollection>"); // until i figure this one out, take it out markOut ( content , "<hits>"); // for those links in the html pages markOut ( content, "rand64="); // for json markOut ( content , "\"currentTimeUTC\":" ); markOut ( content , "\"responseTimeMS\":"); markOut ( content , "\"docsInCollection\":"); // for xml markOut ( content , "<currentTimeUTC>" ); markOut ( content , "<responseTimeMS>"); markOut ( content , "<docsInCollection>"); // indexed 1 day ago markOut ( content,"indexed:"); // modified 1 day ago markOut ( content,"modified:"); // s_gigabitCount... it is perpetually incrementing static counter // in PageResults.cpp markOut(content,"ccc("); markOut(content,"id=fd"); markOut(content,"id=sd"); // for some reason the term freq seems to change a little in // the scoring table markOut(content,"id=tf"); // make checksum. we ignore back to back spaces so this // hash works for <docsInCollection>10 vs <docsInCollection>9 long contentCRC = 0; if ( content ) contentCRC = qa_hash32 ( content ); // note it log("qa: got contentCRC of %lu",contentCRC); // if what we expected, save to disk if not there yet, then // call s_callback() to resume the qa pipeline /* if ( contentCRC == s_expectedCRC ) { // save content if good char fn3[1024]; sprintf(fn3,"%sqa/content.%lu",g_hostdb.m_dir,contentCRC); File ff; ff.set ( fn3 ); if ( ! ff.doesExist() ) { // if not there yet then save it fb2.save(fn3); } // . continue on with the qa process // . which qa function that may be //s_callback(); return; } */ // // if crc of content does not match what was expected then do a diff // so we can see why not // // this means caller does not care about the response if ( ! s_checkCRC ) { //s_callback(); return; } //const char *emsg = "qa: bad contentCRC of %li should be %li " // "\n";//"phase=%li\n"; //fprintf(stderr,emsg,contentCRC,s_expectedCRC);//,s_phase-1); // hash url long urlHash32 = hash32n ( s_url.getUrl() ); // combine test function too since two tests may use the same url long nameHash = hash32n ( s_qt->m_testName ); // combine together urlHash32 = hash32h ( nameHash , urlHash32 ); static bool s_init = false; if ( ! s_init ) { s_init = true; s_ht.set(4,4,1024,NULL,0,false,0,"qaht"); // make symlink //char cmd[512]; //snprintf(cmd,"cd %s/html ;ln -s ../qa ./qa", g_hostdb.m_dir); //system(cmd); char dir[1024]; snprintf(dir,1000,"%sqa",g_hostdb.m_dir); long status = ::mkdir ( dir , S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IXOTH ); if ( status == -1 && errno != EEXIST && errno ) log("qa: Failed to make directory %s: %s.", dir,mstrerror(errno)); // try to load from disk SafeBuf fn; fn.safePrintf("%s/qa/",g_hostdb.m_dir); log("qa: loading crctable.dat"); s_ht.load ( fn.getBufStart() , "crctable.dat" ); } // break up into lines char fn2[1024]; sprintf(fn2,"%sqa/content.%lu",g_hostdb.m_dir,contentCRC); fb2.save ( fn2 ); // look up in hashtable to see what reply crc should be long *val = (long *)s_ht.getValue ( &urlHash32 ); // just return if the same if ( val && contentCRC == *val ) { g_qaOutput.safePrintf("<b style=color:green;>" "passed test</b><br>%s : " "<a href=%s>%s</a> (urlhash=%lu " "crc=<a href=/qa/content.%lu>" "%lu</a>)<br>" "<hr>", s_qt->m_testName, s_url.getUrl(), s_url.getUrl(), urlHash32, contentCRC, contentCRC); return; } if ( ! val ) { // add it so we know s_ht.addKey ( &urlHash32 , &contentCRC ); g_qaOutput.safePrintf("<b style=color:blue;>" "first time testing</b><br>%s : " "<a href=%s>%s</a> " "(urlhash=%lu " "crc=<a href=/qa/content.%lu>%lu" "</a>)<br>" "<hr>", s_qt->m_testName, s_url.getUrl(), s_url.getUrl(), urlHash32, contentCRC, contentCRC); return; } log("qa: crc changed for url %s from %li to %li", s_url.getUrl(),*val,contentCRC); // get response on file SafeBuf fb1; char fn1[1024]; sprintf(fn1,"%sqa/content.%lu",g_hostdb.m_dir, *val); fb1.load(fn1); fb1.nullTerm(); // do the diff between the two replies so we can see what changed char cmd[1024]; sprintf(cmd,"diff %s %s > /tmp/diffout",fn1,fn2); log("qa: %s\n",cmd); system(cmd); g_numErrors++; g_qaOutput.safePrintf("<b style=color:red;>FAILED TEST</b><br>%s : " "<a href=%s>%s</a> (urlhash=%lu)<br>" "<input type=checkbox name=urlhash%lu value=1 " // use ajax to update test crc. if you undo your // check then it should put the old val back. // when you first click the checkbox it should // gray out the diff i guess. "onclick=submitchanges(%lu,%lu);> " "Accept changes" "<br>" "original on left, new on right. " "oldcrc = <a href=/qa/content.%lu>%lu</a>" " != <a href=/qa/content.%lu>%lu</a> = newcrc" "<br>diff output follows:<br>" "<pre id=%lu style=background-color:0xffffff;>", s_qt->m_testName, s_url.getUrl(), s_url.getUrl(), urlHash32, // input checkbox name field urlHash32, // submitchanges() parms urlHash32, contentCRC, // original/old content.%lu *val, *val, // new content.%lu contentCRC, contentCRC, // for the pre tag id: urlHash32); // store in output SafeBuf sb; sb.load("/tmp/diffout"); g_qaOutput.htmlEncode ( sb.getBufStart() ); g_qaOutput.safePrintf("</pre><br><hr>"); // if this is zero allow it to slide by. it is learning mode i guess. // so we can learn what crc we need to use. // otherwise, stop right there for debugging //if ( s_expectedCRC != 0 ) exit(1); // keep on going //s_callback(); }
bool sendPageThesaurus( TcpSocket *s, HttpRequest *r ) { SafeBuf p; char getBuf[64]; // holds extra values for GET method char formBuf[256]; // holds extra values for forms snprintf(getBuf, 64, "c=%s", r->getString("c", 0, "")); snprintf(formBuf, 256, "<input type=hidden name=\"c\" value=\"%s\">", //"<input type=hidden name=\"pwd\" value=\"%s\">", r->getString("c", 0, "")); g_pages.printAdminTop( &p, s, r); if (r->getLong("cancel", 0) != 0) { g_thesaurus.cancelRebuild(); p.safePrintf("<br><br>\n"); p.safePrintf( "<center><b><font color=#ff0000>" "rebuild canceled" "</font></b></center>"); } if (r->getLong("rebuild", 0) != 0) { bool full = r->getLong("full", 0); p.safePrintf("<br><br>\n"); if (g_thesaurus.rebuild(0, full)) { p.safePrintf( "<center><b><font color=#ff0000>" "error starting rebuild, check log for details" "</font></b></center>"); } else { p.safePrintf( "<center><b><font color=#ff0000>" "rebuild started" "</font></b></center>"); } } if (r->getLong("rebuildaff", 0) != 0) { bool full = r->getLong("full", 0); p.safePrintf("<br><br>\n"); if (g_thesaurus.rebuildAffinity(0, full)) { p.safePrintf( "<center><b><font color=#ff0000>" "error starting rebuild, check log for details" "</font></b></center>"); } else { p.safePrintf( "<center><b><font color=#ff0000>" "rebuild started" "</font></b></center>"); } } if (r->getLong("distribute", 0) != 0) { char cmd[1024]; p.safePrintf("<br><br>\n"); if (g_thesaurus.m_affinityState) { p.safePrintf( "<center><b><font color=#ff0000>" "cannot distribute during rebuild" "</font></b></center>"); } else { for ( long i = 0; i < g_hostdb.getNumHosts() ; i++ ) { Host *h = g_hostdb.getHost(i); snprintf(cmd, 512, "rcp -r " "./dict/thesaurus.* " "%s:%s/dict/ &", iptoa(h->m_ip), h->m_dir); log(LOG_INFO, "admin: %s", cmd); system( cmd ); } p.safePrintf( "<center><b><font color=#ff0000>" "data distributed" "</font></b></center>"); } } if (r->getLong("reload", 0) != 0) { p.safePrintf("<br><br>\n"); if (r->getLong("cast", 0) != 0) { p.safePrintf( "<center><b><font color=#ff0000>" "reload command broadcast" "</font></b></center>"); } else if (g_thesaurus.init()) { p.safePrintf( "<center><b><font color=#ff0000>" "thesaurus data reloaded" "</font></b></center>"); } else { p.safePrintf( "<center><b><font color=#ff0000>" "error reloading thesaurus data" "</font></b></center>"); } } long manualAddLen = 0; char *manualAdd = NULL; SafeBuf manualAddBuf; if ((manualAdd = r->getString("manualadd", &manualAddLen))) { trimWhite(manualAdd); manualAddLen = gbstrlen(manualAdd); File manualFile; manualFile.set(g_hostdb.m_dir, "dict/thesaurus-manual.txt"); if (manualFile.open(O_WRONLY | O_CREAT | O_TRUNC) && (manualFile.write(manualAdd, manualAddLen, 0) == manualAddLen)) { char newl = '\n'; // for write() if (manualAdd[manualAddLen-1] != '\n') manualFile.write(&newl, 1, manualAddLen); p.safePrintf( "<center><b><font color=#ff0000>" "updated manual add file sucessfully" "</font></b></center>"); } else { p.safePrintf( "<center><b><font color=#ff0000>" "error writing manual add file" "</font></b></center>"); } } else { char ff[PATH_MAX]; snprintf(ff, PATH_MAX, "%sdict/thesaurus-manual.txt", g_hostdb.m_dir); if (manualAddBuf.fillFromFile(ff)) { if (*(manualAddBuf.getBuf()-1) != '\n') manualAddBuf.pushChar('\n'); manualAdd = manualAddBuf.getBufStart(); manualAddLen = manualAddBuf.length(); } } long affinityAddLen = 0; char *affinityAdd = NULL; SafeBuf affinityAddBuf; if ((affinityAdd = r->getString("affinityadd", &affinityAddLen))) { trimWhite(affinityAdd); affinityAddLen = gbstrlen(affinityAdd); File affinityFile; affinityFile.set(g_hostdb.m_dir, "dict/thesaurus-affinity.txt"); if (affinityFile.open(O_WRONLY | O_CREAT | O_TRUNC) && (affinityFile.write(affinityAdd, affinityAddLen, 0) == affinityAddLen)) { char newl = '\n'; // for write() if (affinityAdd[affinityAddLen-1] != '\n') affinityFile.write(&newl, 1, affinityAddLen); p.safePrintf( "<center><b><font color=#ff0000>" "updated affinity add file sucessfully" "</font></b></center>"); } else { p.safePrintf( "<center><b><font color=#ff0000>" "error writing affinity add file" "</font></b></center>"); } } else { char ff[PATH_MAX]; snprintf(ff, PATH_MAX, "%sdict/thesaurus-affinity.txt", g_hostdb.m_dir); if (affinityAddBuf.fillFromFile(ff)) { if (*(affinityAddBuf.getBuf()-1) != '\n') affinityAddBuf.pushChar('\n'); affinityAdd = affinityAddBuf.getBufStart(); affinityAddLen = affinityAddBuf.length(); } } char *syn = r->getString("synonym"); long len = 0; if (syn) len = gbstrlen(syn); if (len) { SynonymInfo info; bool r = g_thesaurus.getAllInfo(syn, &info, len, SYNBIT_ALL); p.safePrintf("<br><br>\n"); p.safePrintf ( "<table cellpadding=4 width=100%% bgcolor=#%s border=1>" "<tr>" "<td colspan=2 bgcolor=#%s>" "<center><b>Synonym List (%ld)</b></center>" "</td>" "</tr>\n", LIGHT_BLUE, DARK_BLUE, info.m_numSyns); if (r) { p.safePrintf("<tr>" "<td align=right><tt>%s</tt></td>" "<td align=left>" "<tt>1.000/%08lX (1.000/%08lX)</tt>" "</td>" "</tr>\n", syn, MAX_AFFINITY, MAX_AFFINITY); for (long i = 0; i < info.m_numSyns; i++) { // get the reverse affinity as well long aff = g_thesaurus.getAffinity( info.m_syn[i], syn, info.m_len[i], len); p.safePrintf( "<tr>" "<td width=40%% align=right>" "<tt>"); p.safeMemcpy(info.m_syn[i], info.m_len[i]); p.safePrintf("</tt>" "</td>" "<td width=60%% align=left>" "<tt>"); if (info.m_affinity[i] >= 0) { p.safePrintf("%0.3f/%08lX ", (float)info.m_affinity[i] / MAX_AFFINITY, info.m_affinity[i]); } else { p.safePrintf("u "); } if (aff >= 0) { p.safePrintf("(%0.3f/%08lX) ", (float)aff / MAX_AFFINITY, aff); } else { p.safePrintf("(u) "); } p.safePrintf("(%ld) (%ld) (%ld) (%ld) " "(%lld) (%lld)", (long)info.m_type[i], (long)info.m_sort[i], info.m_firstId[i], info.m_lastId[i], info.m_leftSynHash[i], info.m_rightSynHash[i]); for (int j = info.m_firstId[i]; j <= info.m_lastId[i]; j++) { p.safePrintf(" (%lld)", info.m_termId[j]); } p.safePrintf( "</tt>" "</td>" "</tr>\n"); } p.safePrintf("</table>"); } else { p.safePrintf("<tr>" "<td align=center><font color=#FF0000>" "synonym not found: %s" "</font></td>" "</tr>\n", syn); } } p.safePrintf ( "<br><br>\n" ); p.safePrintf ( "<table cellpadding=4 width=100%% bgcolor=#%s border=1>" "<tr>" "<td colspan=2 bgcolor=#%s>" "<center><b>Thesaurus Controls" "</b></center></td>" "</tr>\n", LIGHT_BLUE, DARK_BLUE); p.safePrintf ( "<tr>" "<td width=37%%><b>rebuild all data</b><br>" "<font size=1>" "rebuilds synonyms and then begins the rebuild process for " "affinity data; this should only be run on one host, as the " "data is copied when the process is finished; full rebuild " "does not use existing affinity data" "</font>" "</td>" "<td width=12%% bgcolor=#0000ff>" "<center><b><a href=\"/master/thesaurus?rebuild=1&%s\">" "rebuild all data</a> <a href=\"/master/thesaurus?" "rebuild=1&full=1&%s\">(full)</a></b></center>" "</td>" "</tr>\n", getBuf, getBuf); p.safePrintf ( "<tr>" "<td width=37%%><b>distribute data</b><br>" "<font size=1>" "distributes all thesaurus data to all hosts, this is " "normally done automatically but if there was a problem " "with the copy, this lets you do it manually" "</font>" "</td>" "<td width=12%% bgcolor=#0000ff>" "<center><b><a href=\"/master/thesaurus?distribute=1&%s\">" "distribute data</a></b></center>" "</td>" "</tr>\n", getBuf); p.safePrintf ( "<tr>" "<td width=37%%><b>reload data</b><br>" "<font size=1>" "reloads the synonyms and affinity table on this host only" "</font>" "</td>" "<td width=12%% bgcolor=#0000ff>" "<center><b>" "<a href=\"/master/thesaurus?reload=1&cast=0&%s\">" "reload data</a></b></center>" "</td>" "</tr>\n", getBuf); p.safePrintf ( "<tr>" "<td width=37%%><b>reload data (all hosts)</b><br>" "<font size=1>" "reloads the synonyms and affinity table on all hosts" "</font>" "</td>" "<td width=12%% bgcolor=#0000ff>" "<center><b>" "<a href=\"/master/thesaurus?reload=1&cast=1&%s\">" "reload data (all hosts)</a></b></center>" "</td>" "</tr>\n", getBuf); p.safePrintf ( "<tr>" "<td width=37%%><b>list synonyms</b><br>" "<font size=1>" "enter a word here to list all synonym entries and their " "affinities" "</font>" "</td>" "<td width=12%%>" "<form action=\"/master/thesaurus>\">" "<input type=text name=synonym size=20>" "<input type=submit value=Submit>" "%s" "</form></td>" "</tr>\n", formBuf); p.safePrintf ( "<tr>" "<td colspan=2 bgcolor=#%s>" "<center><b>Affinity Controls" "</b></center></td>" "</tr>\n", DARK_BLUE); p.safePrintf ( "<tr>" "<td width=37%%><b>cancel running rebuild</b><br>" "<font size=1>" "cancels the rebuild and throws all intermediate data away" "</font>" "</td>" "<td width=12%% bgcolor=#0000ff>" "<center><b><a href=\"/master/thesaurus?cancel=1&%s\">" "cancel running rebuild</a></b></center>" "</td>" "</tr>\n", getBuf); p.safePrintf ( "<tr>" "<td width=37%%><b>rebuild affinity only</b><br>" "<font size=1>" "begins the rebuild process for affinity data, has no " "effect if a rebuild is already in progress; full rebuild " "does not reuse existing affinity data" "</font>" "</td>" "<td width=12%% bgcolor=#0000ff>" "<center><b><a href=\"/master/thesaurus?rebuildaff=1&%s\">" "rebuild affinity</a> <a href=\"/master/thesaurus?" "rebuildaff=1&full=1&%s\">(full)</a></b></center>" "</td>" "</tr>\n", getBuf, getBuf); p.safePrintf ( "<tr>" "<td colspan=2 bgcolor=#%s>" "<center><b>Manual File Controls" "</b></td>" "</tr>\n", DARK_BLUE); p.safePrintf ( "<tr>" "<td align=center colspan=2>"); p.safePrintf( "<b>manually added pairs</b><br>\n" "<font size=1>place word pairs here that should be linked " "as synonyms, one pair per line, seperated by a pipe '|' " "character, optionally followed by another pipe and a type " "designation; any badly formatted lines will be silently " "ignored</font><br>\n" "<form action=\"/master/thesaurus\" method=post>" "<textarea name=\"manualadd\" rows=20 cols=80>"); if (manualAdd && manualAddLen) { p.htmlEncode(manualAdd, manualAddLen, true); } p.safePrintf ( "</textarea><br>" "<input type=submit value=Submit>" "<input type=reset value=Reset>" "%s" "</form></td>" "</tr>\n", formBuf); p.safePrintf ( "<tr>" "<td align=center colspan=2>" "<b>affinity value overrides</b><br>\n" "<font size=1>place word/phrase pairs here that should have " "there affinity values overridden, format is " "\"word1|word2|value\", where value is a floating point, " "integer (either decimal or hex), or the word \"max\"; " "any badly formatted lines will be silently ignored; note " "that these pairs will only work if the thesaurus otherwise " "has an entry for them, so add them to the manual add file " "above if need be</font><br>\n" "<form action=\"/master/thesaurus\" method=post>" "<textarea name=\"affinityadd\" rows=20 cols=80>"); if (affinityAdd && affinityAddLen) { p.htmlEncode(affinityAdd, affinityAddLen, true); } p.safePrintf ( "</textarea><br>" "<input type=submit value=Submit>" "<input type=reset value=Reset>" "%s" "</form></td>" "</tr>\n", formBuf); p.safePrintf ( "</table>\n" ); p.safePrintf ( "<br><br>\n" ); p.safePrintf ( "<table cellpadding=4 width=100%% bgcolor=#%s border=1>" "<tr>" "<td colspan=2 bgcolor=#%s>" "<center><b>Affinity Builder Status" "</b></td>" "</tr>\n", LIGHT_BLUE, DARK_BLUE); long long a, b, c, d, e, f, g, h, i, j, k; StateAffinity *aff = g_thesaurus.m_affinityState; if (!aff) { p.safePrintf ( "<tr><td colspan=2>" "<center><b>Not running</b></center>" "</td></tr>\n"); a = b = c = d = e = f = g = h = i = j = k = 0; } else { a = aff->m_oldTable->getNumSlotsUsed(); b = aff->m_oldTable->getNumSlotsUsed() - aff->m_n; c = aff->m_n; d = (gettimeofdayInMilliseconds() - aff->m_time) / 1000; if (!d || !(c / d)) { e = 0; } else { e = b / (c / d); } f = aff->m_sent; g = aff->m_recv; h = aff->m_errors; i = aff->m_old; j = aff->m_cache; k = aff->m_hitsTable.getNumSlotsUsed(); } p.safePrintf ( "<tr><td><b># of total pairs</b></td>" "<td>%lli</td></tr>\n" "<tr><td><b># of pairs remaining</b></td>" "<td>%lli</td></tr>\n" "<tr><td><b># of pairs processed</b></td>" "<td>%lli</td></tr>\n" "<tr><td><b>elapsed time in seconds</b></td>" "<td>%lli</td></tr>\n" "<tr><td><b>estimated remaining time in seconds</b></td>" "<td>%lli</td></tr>\n" "<tr><td><b># of requests sent</b></td>" "<td>%lli</td></tr>\n" "<tr><td><b># of requests received</b></td>" "<td>%lli</td></tr>\n" "<tr><td><b># of request errors</b></td>" "<td>%lli</td></tr>\n" "<tr><td><b># of old values reused</b></td>" "<td>%lli</td></tr>\n" "<tr><td><b># of cache hits</b></td>" "<td>%lli</td></tr>\n" "<tr><td><b>cache size</b></td>" "<td>%lli</td></tr>\n", a, b, c, d, e, f, g, h, i, j, k); p.safePrintf ( "</table>\n" ); return g_httpServer.sendDynamicPage ( s, p.getBufStart(), p.length() ); }