Project

General

Profile

« Previous | Next » 

Revision 6448

do not send <systemMetadata> with the <docInfo> replication information - this is handled by the Hazelcast shared map

View differences:

ReplicationHandler.java
26 26

  
27 27
package edu.ucsb.nceas.metacat.replication;
28 28

  
29
import java.io.ByteArrayInputStream;
30
import java.io.InputStream;
31
import java.io.StringReader;
32
import java.net.InetAddress;
33
import java.net.URL;
34
import java.net.UnknownHostException;
35
import java.sql.PreparedStatement;
36
import java.sql.ResultSet;
37
import java.sql.SQLException;
38
import java.text.DateFormat;
39
import java.text.ParseException;
40
import java.util.Date;
41
import java.util.Hashtable;
42
import java.util.TimerTask;
43
import java.util.Vector;
44

  
45
import org.apache.log4j.Logger;
46
import org.dataone.service.types.v1.SystemMetadata;
47
import org.dataone.service.util.TypeMarshaller;
48
import org.xml.sax.ContentHandler;
49
import org.xml.sax.ErrorHandler;
50
import org.xml.sax.InputSource;
51
import org.xml.sax.SAXException;
52
import org.xml.sax.XMLReader;
53
import org.xml.sax.helpers.DefaultHandler;
54
import org.xml.sax.helpers.XMLReaderFactory;
55

  
29 56
import edu.ucsb.nceas.metacat.CatalogMessageHandler;
30 57
import edu.ucsb.nceas.metacat.DBUtil;
31 58
import edu.ucsb.nceas.metacat.DocInfoHandler;
......
43 70
import edu.ucsb.nceas.metacat.properties.PropertyService;
44 71
import edu.ucsb.nceas.metacat.shared.HandlerException;
45 72
import edu.ucsb.nceas.metacat.util.MetacatUtil;
46
import edu.ucsb.nceas.metacat.util.ReplicationUtil;
47
import edu.ucsb.nceas.metacat.IdentifierManager;
48 73
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
49 74

  
50
import java.sql.*;
51
import java.util.*;
52
import java.util.Date;
53
import java.io.*;
54
import java.net.*;
55
import java.text.*;
56 75

  
57
import org.apache.log4j.Logger;
58
import org.dataone.service.types.v1.SystemMetadata;
59
import org.dataone.service.util.TypeMarshaller;
60
import org.xml.sax.ContentHandler;
61
import org.xml.sax.ErrorHandler;
62
import org.xml.sax.InputSource;
63
import org.xml.sax.SAXException;
64
import org.xml.sax.XMLReader;
65
import org.xml.sax.helpers.XMLReaderFactory;
66
import org.xml.sax.helpers.DefaultHandler;
67 76

  
68

  
69

  
70 77
/**
71 78
 * This class handles deltaT replication checking.  Whenever this TimerTask
72 79
 * is fired it checks each server in xml_replication for updates and updates
......
373 380
      logReplication.info("ReplicationHandler.handleSingleXMLDocument - Sending message: " + docinfoUrl.toString());
374 381
      String docInfoStr = ReplicationService.getURLContent(docinfoUrl);
375 382
      
376
      // strip out the system metadata portion
377
      String systemMetadataXML = ReplicationUtil.getSystemMetadataContent(docInfoStr);
378
   	  docInfoStr = ReplicationUtil.getContentWithoutSystemMetadata(docInfoStr);
379
      
380 383
      docinfoParser.parse(new InputSource(new StringReader(docInfoStr)));
381 384
      Hashtable<String, String> docinfoHash = dih.getDocInfo();
382 385
      // Get home server of the docid
......
440 443
          }
441 444
      }
442 445
      
443
      // process system metadata
444
      if (systemMetadataXML != null) {
445
    	  SystemMetadata sysMeta = 
446
    		  TypeMarshaller.unmarshalTypeFromStream(
447
    				  SystemMetadata.class, 
448
    				  new ByteArrayInputStream(systemMetadataXML.getBytes("UTF-8")));
449
    	  HazelcastService.getInstance().getSystemMetadataMap().put(sysMeta.getIdentifier(), sysMeta);
450
      }
451
      
452 446
      logReplication.info("ReplicationHandler.handleSingleXMLDocument - Successfully replicated doc " + accNumber);
453 447
      if (tableName.equals(DocumentImpl.DOCUMENTTABLE))
454 448
      {
......
529 523

  
530 524
      String docInfoStr = ReplicationService.getURLContent(docinfoUrl);
531 525
      
532
      // strip out the system metadata portion
533
      String systemMetadataXML = ReplicationUtil.getSystemMetadataContent(docInfoStr);
534
   	  docInfoStr = ReplicationUtil.getContentWithoutSystemMetadata(docInfoStr);  
535
   	  
536 526
      docinfoParser.parse(new InputSource(new StringReader(docInfoStr)));
537 527
      Hashtable<String, String> docinfoHash = dih.getDocInfo();
538 528
      
......
589 579
            }
590 580
        }
591 581
        
592
        //process guid
593
     // process system metadata
594
        if (systemMetadataXML != null) {
595
      	  SystemMetadata sysMeta = 
596
      		TypeMarshaller.unmarshalTypeFromStream(
597
      				  SystemMetadata.class, 
598
      				  new ByteArrayInputStream(systemMetadataXML.getBytes("UTF-8")));
599
      	  HazelcastService.getInstance().getSystemMetadataMap().put(sysMeta.getIdentifier(), sysMeta);
600
        }
601
        
602 582
        logReplication.info("ReplicationHandler.handleSingleDataFile - Successfully to write datafile " + accNumber);
603 583
        /*MetacatReplication.replLog("wrote datafile " + accNumber + " from " +
604 584
                                    remote server);*/

Also available in: Unified diff