Project

General

Profile

« Previous | Next » 

Revision 3233

Added by Jing Tao over 17 years ago

Add even log in replication.

View differences:

src/edu/ucsb/nceas/metacat/MetacatReplication.java
56 56
  private static final String FIRSTTIME  = "firsttimedreplication";
57 57
  private static final int    TIMEINTERVALLIMIT = 7200000;
58 58
  private static Logger logMetacat = Logger.getLogger(MetacatReplication.class);
59
  public static final String REPLICATIONUSER = "replication";
59 60

  
60 61
  /**
61 62
   * Initialize the servlet by creating appropriate database connections
......
219 220
    else if ( action.equals("forcereplicatedatafile") )
220 221
    {
221 222
      //read a specific docid from remote host, and store it into local host
222
      handleForceReplicateDataFileRequest(params);
223
      handleForceReplicateDataFileRequest(params, request);
223 224

  
224 225
    }
225 226
    else
......
299 300

  
300 301
    } else if ( action.equals("forcereplicate") ) {
301 302
      //read a specific docid from remote host, and store it into local host
302
      handleForceReplicateRequest(out, params, response);
303
      handleForceReplicateRequest(out, params, response, request);
303 304

  
304 305
    } else if ( action.equals(FORCEREPLICATEDELETE) ) {
305 306
      //read a specific docid from remote host, and store it into local host
306
      handleForceReplicateDeleteRequest(out, params, response);
307
      handleForceReplicateDeleteRequest(out, params, response, request);
307 308

  
308 309
    } else if ( action.equals("update") ) {
309 310
      //request an update list from the server
......
575 576
   * Then store it in local database.
576 577
   */
577 578
  private void handleForceReplicateRequest(PrintWriter out, Hashtable params,
578
                                           HttpServletResponse response)
579
                                           HttpServletResponse response, HttpServletRequest request)
579 580
  {
580 581
    String server = ((String[])params.get("server"))[0]; // the server that
581 582
    String docid = ((String[])params.get("docid"))[0]; // sent the document
......
657 658

  
658 659
      MetacatReplication.replLog("document " + docid + " added to DB with " +
659 660
                                 "action " + dbaction);
661
      EventLog.getInstance().log(request.getRemoteAddr(), REPLICATIONUSER, docid, dbaction);
660 662
    }//try
661 663
    catch(Exception e)
662 664
    {
......
680 682
 * document
681 683
 */
682 684
private void handleForceReplicateDeleteRequest(PrintWriter out, Hashtable params,
683
                                         HttpServletResponse response)
685
                                         HttpServletResponse response, HttpServletRequest request)
684 686
{
685 687
  String server = ((String[])params.get("server"))[0]; // the server that
686 688
  String docid = ((String[])params.get("docid"))[0]; // sent the document
......
692 694
    logMetacat.info("Force replication delete docid: "+docid);
693 695
    DocumentImpl.delete(docid, null, null, server);
694 696
    MetacatReplication.replLog("document " + docid + " was successfully deleted ");
697
    EventLog.getInstance().log(request.getRemoteAddr(), REPLICATIONUSER, docid, "delete");
695 698
    logMetacat.info("document " + docid + " was successfully deleted ");
696 699
  }
697 700
  catch(Exception e)
......
712 715
   * readdata request to the requesting server (remote server) for the specified
713 716
   * docid. Then store it in local database and file system
714 717
   */
715
  private void handleForceReplicateDataFileRequest(Hashtable params)
718
  private void handleForceReplicateDataFileRequest(Hashtable params, HttpServletRequest request)
716 719
  {
717 720

  
718 721
    //make sure there is some parameters
......
804 807
                            docName, docType, docid, user,docHomeServer,server, 
805 808
                            DocumentImpl.DOCUMENTTABLE, false, createdDate, updatedDate);
806 809
                            //false means non-timed replication
810
        MetacatReplication.replLog("datafile " + docid + " added to DB with " +
811
                "action " + dbaction);
812
        EventLog.getInstance().log(request.getRemoteAddr(), REPLICATIONUSER, docid, dbaction);
807 813
     }
808 814

  
809 815

  
810 816

  
811
    MetacatReplication.replLog("datafile " + docid + " added to DB with " +
812
                                 "action " + dbaction);
817
    
813 818
    }
814 819
    catch(Exception e)
815 820
    {

Also available in: Unified diff