Revision 2105
Added by Duane Costa about 20 years ago
Harvester.java | ||
---|---|---|
177 | 177 |
else { |
178 | 178 |
System.out.println(" hours."); |
179 | 179 |
} |
180 |
//Thread.sleep(delay * oneHour); |
|
181 |
Thread.sleep(delay * oneSecond); |
|
180 |
Thread.sleep(delay * oneHour); |
|
182 | 181 |
} |
183 | 182 |
catch (InterruptedException e) { |
184 | 183 |
System.err.println("InterruptedException: " + e.getMessage()); |
... | ... | |
232 | 231 |
private int detailLogID; |
233 | 232 |
|
234 | 233 |
/** Email address of the Harvester Administrator */ |
235 |
private String harvesterAdministrator;
|
|
234 |
String harvesterAdministrator; |
|
236 | 235 |
|
237 | 236 |
/** Highest HARVEST_LOG_ID primary key in the HARVEST_LOG table */ |
238 | 237 |
private int harvestLogID; |
... | ... | |
473 | 472 |
|
474 | 473 |
|
475 | 474 |
/** |
476 |
* Prints all harvest log entries for this harvest run. |
|
475 |
* Prints harvest log entries for this harvest run. Entries may be filtered |
|
476 |
* for a particular site, or all entries may be printed. |
|
477 | 477 |
* |
478 |
* @param out the PrintStream object to write to |
|
478 |
* @param out the PrintStream object to write to |
|
479 |
* @param maxCodeLevel the maximum code level that should be printed, |
|
480 |
* e.g. "warning". Any log entries higher than this |
|
481 |
* level will not be printed. |
|
482 |
* @param siteScheduleID if greater than 0, indicates that the log |
|
483 |
* entry should only be printed for a particular site |
|
484 |
* as identified by its siteScheduleID. if 0, then |
|
485 |
* print output for all sites. |
|
479 | 486 |
*/ |
480 |
private void printHarvestLog(PrintStream out) { |
|
487 |
void printHarvestLog(PrintStream out, |
|
488 |
String maxCodeLevel, |
|
489 |
int siteScheduleID |
|
490 |
) { |
|
481 | 491 |
HarvestLog harvestLog; |
492 |
int logSiteScheduleID; |
|
493 |
int nErrors = 0; |
|
494 |
String phrase; |
|
482 | 495 |
|
483 | 496 |
for (int i = 0; i < harvestLogList.size(); i++) { |
484 | 497 |
harvestLog = (HarvestLog) harvestLogList.get(i); |
485 |
harvestLog.printOutput(out); |
|
498 |
logSiteScheduleID = harvestLog.getSiteScheduleID(); |
|
499 |
|
|
500 |
if ((siteScheduleID == 0) || (siteScheduleID == logSiteScheduleID)) { |
|
501 |
if (harvestLog.isErrorEntry()) { |
|
502 |
nErrors++; |
|
503 |
} |
|
504 |
} |
|
486 | 505 |
} |
506 |
|
|
507 |
out.println(marker); |
|
508 |
out.println("*"); |
|
509 |
out.println("* METACAT HARVESTER REPORT"); |
|
510 |
out.println("*"); |
|
511 |
|
|
512 |
if (nErrors > 0) { |
|
513 |
phrase = (nErrors == 1) ? " ERROR WAS " : " ERRORS WERE "; |
|
514 |
out.println("* A TOTAL OF " + nErrors + phrase + "DETECTED."); |
|
515 |
out.println("* Please see the log entries below for additonal details."); |
|
516 |
} |
|
517 |
else { |
|
518 |
out.println("* NO ERRORS WERE DETECTED DURING THIS HARVEST."); |
|
519 |
} |
|
520 |
|
|
521 |
out.println("*"); |
|
522 |
out.println(marker); |
|
523 |
|
|
524 |
for (int i = 0; i < harvestLogList.size(); i++) { |
|
525 |
harvestLog = (HarvestLog) harvestLogList.get(i); |
|
526 |
logSiteScheduleID = harvestLog.getSiteScheduleID(); |
|
527 |
if ((siteScheduleID == 0) || (siteScheduleID == logSiteScheduleID)) { |
|
528 |
harvestLog.printOutput(out, maxCodeLevel); |
|
529 |
} |
|
530 |
} |
|
487 | 531 |
} |
488 | 532 |
|
489 | 533 |
|
... | ... | |
663 | 707 |
/** |
664 | 708 |
* Sends a report to the Harvester administrator. The report prints each log |
665 | 709 |
* entry pertaining to this harvest run. |
710 |
* |
|
711 |
* @param maxCodeLevel the maximum code level that should be printed, |
|
712 |
* e.g. "warning". Any log entries higher than this |
|
713 |
* level will not be printed. |
|
666 | 714 |
*/ |
667 |
void reportToAdministrator() { |
|
715 |
void reportToAdministrator(String maxCodeLevel) {
|
|
668 | 716 |
PrintStream body; |
669 | 717 |
String from = harvesterAdministrator; |
670 | 718 |
MailMessage msg; |
719 |
int siteScheduleID = 0; |
|
671 | 720 |
String subject = "Report from Metacat Harvester"; |
672 | 721 |
String to = harvesterAdministrator; |
673 | 722 |
|
... | ... | |
681 | 730 |
msg.to(to); |
682 | 731 |
msg.setSubject(subject); |
683 | 732 |
body = msg.getPrintStream(); |
684 |
printHarvestLog(body); |
|
733 |
printHarvestLog(body, maxCodeLevel, siteScheduleID);
|
|
685 | 734 |
msg.sendAndClose(); |
686 | 735 |
} |
687 | 736 |
catch (IOException e) { |
... | ... | |
697 | 746 |
* of Metacat and disconnecting from the database. |
698 | 747 |
*/ |
699 | 748 |
private void shutdown() { |
749 |
String maxCodeLevel = "debug"; // Print all log entries from level 1 |
|
750 |
// ("error") to level 5 ("debug") |
|
751 |
int siteScheduleID = 0; |
|
752 |
|
|
700 | 753 |
// Log shutdown operation |
701 | 754 |
System.out.println("Shutting Down Harvester"); |
702 | 755 |
addLogEntry(0, "Shutting Down Harvester", "HarvesterShutdown", 0, null, ""); |
... | ... | |
712 | 765 |
System.out.println("Database access failed " + e); |
713 | 766 |
} |
714 | 767 |
|
715 |
printHarvestLog(System.out); // Print log to standard output |
|
716 |
reportToAdministrator(); // Send a copy of the log to harvester admin |
|
768 |
// Print log to standard output and then email the Harvester administrator |
|
769 |
printHarvestLog(System.out, maxCodeLevel, siteScheduleID); |
|
770 |
reportToAdministrator(maxCodeLevel); // Send a copy to harvester admin |
|
717 | 771 |
} |
718 | 772 |
|
719 | 773 |
|
Also available in: Unified diff
Implement sending email reports to harvest administrator and site administrator