Revision 1583
Added by Jing Tao over 21 years ago
src/edu/ucsb/nceas/metacat/MetacatReplication.java | ||
---|---|---|
519 | 519 |
}//try |
520 | 520 |
catch(Exception e) |
521 | 521 |
{ |
522 |
MetacatReplication.replErrorLog("document " + docid + |
|
523 |
" failed to added to DB with " + |
|
524 |
"action " + dbaction + " because "+ |
|
525 |
e.getMessage()); |
|
526 |
MetaCatUtil.debugMessage("ERROR in MetacatReplication.handleForceReplicate" + |
|
527 |
"Request(): " + e.getMessage(), 30); |
|
522 | 528 |
|
523 |
System.out.println("ERROR in MetacatReplication.handleForceReplicate" + |
|
524 |
"Request(): " + e.getMessage()); |
|
525 |
e.printStackTrace(); |
|
526 | 529 |
}//catch |
527 | 530 |
finally |
528 | 531 |
{ |
... | ... | |
627 | 630 |
|
628 | 631 |
|
629 | 632 |
|
630 |
MetacatReplication.replLog("document " + docid + " added to DB with " +
|
|
633 |
MetacatReplication.replLog("datafile " + docid + " added to DB with " +
|
|
631 | 634 |
"action " + dbaction); |
632 |
} catch(Exception e) |
|
635 |
} |
|
636 |
catch(Exception e) |
|
633 | 637 |
{ |
634 | 638 |
|
635 |
//util.returnConnection(conn); |
|
636 |
util.debugMessage |
|
639 |
MetacatReplication.replErrorLog("Datafile " + docid + |
|
640 |
" failed to added to DB with " + |
|
641 |
"action " + dbaction + " because "+ |
|
642 |
e.getMessage()); |
|
643 |
MetaCatUtil.debugMessage |
|
637 | 644 |
("ERROR in MetacatReplication.handleForceDataFileReplicate" + |
638 | 645 |
"Request(): " + e.getMessage(), 30); |
639 | 646 |
} |
... | ... | |
1624 | 1631 |
} |
1625 | 1632 |
|
1626 | 1633 |
/** |
1634 |
* Method for writing replication messages to a log file specified in |
|
1635 |
* metacat.properties |
|
1636 |
*/ |
|
1637 |
public static void replErrorLog(String message) |
|
1638 |
{ |
|
1639 |
try |
|
1640 |
{ |
|
1641 |
FileOutputStream fos = new FileOutputStream( |
|
1642 |
util.getOption("replicationerrorlog"), true); |
|
1643 |
PrintWriter pw = new PrintWriter(fos); |
|
1644 |
SimpleDateFormat formatter = new SimpleDateFormat ("yy-MM-dd HH:mm:ss"); |
|
1645 |
java.util.Date localtime = new java.util.Date(); |
|
1646 |
String dateString = formatter.format(localtime); |
|
1647 |
dateString += " :: " + message; |
|
1648 |
//time stamp each entry |
|
1649 |
pw.println(dateString); |
|
1650 |
pw.flush(); |
|
1651 |
} |
|
1652 |
catch(Exception e) |
|
1653 |
{ |
|
1654 |
System.out.println("error writing to replication log from " + |
|
1655 |
"MetacatReplication.replLog: " + e.getMessage()); |
|
1656 |
//e.printStackTrace(System.out); |
|
1657 |
} |
|
1658 |
} |
|
1659 |
|
|
1660 |
/** |
|
1627 | 1661 |
* Returns true if the replicate field for server in xml_replication is 1. |
1628 | 1662 |
* Returns false otherwise |
1629 | 1663 |
*/ |
Also available in: Unified diff
Revise update method. Every write action will check out a db connection. So it can handle a huge mount of write action.