Revision 6447
Added by ben leinfelder over 12 years ago
ReplicationHandler.java | ||
---|---|---|
39 | 39 |
import edu.ucsb.nceas.metacat.database.DBConnection; |
40 | 40 |
import edu.ucsb.nceas.metacat.database.DBConnectionPool; |
41 | 41 |
import edu.ucsb.nceas.metacat.database.DatabaseService; |
42 |
import edu.ucsb.nceas.metacat.dataone.hazelcast.HazelcastService; |
|
42 | 43 |
import edu.ucsb.nceas.metacat.properties.PropertyService; |
43 | 44 |
import edu.ucsb.nceas.metacat.shared.HandlerException; |
44 | 45 |
import edu.ucsb.nceas.metacat.util.MetacatUtil; |
... | ... | |
445 | 446 |
TypeMarshaller.unmarshalTypeFromStream( |
446 | 447 |
SystemMetadata.class, |
447 | 448 |
new ByteArrayInputStream(systemMetadataXML.getBytes("UTF-8"))); |
448 |
String guid = sysMeta.getIdentifier().getValue(); |
|
449 |
if (!IdentifierManager.getInstance().identifierExists(guid)) { |
|
450 |
logReplication.debug("Creating system metadata and guid/docid mapping for docid " + docinfoHash.get("docid") + " and guid: " + guid); |
|
451 |
IdentifierManager.getInstance().createMapping(guid, docinfoHash.get("docid")); |
|
452 |
IdentifierManager.getInstance().createSystemMetadata(sysMeta); |
|
453 |
} else { |
|
454 |
logReplication.debug("Updating guid/docid mapping for docid " + docinfoHash.get("docid") + " and guid: " + guid); |
|
455 |
IdentifierManager.getInstance().updateMapping(guid, docinfoHash.get("docid")); |
|
456 |
} |
|
457 |
IdentifierManager.getInstance().updateSystemMetadata(sysMeta); |
|
449 |
HazelcastService.getInstance().getSystemMetadataMap().put(sysMeta.getIdentifier(), sysMeta); |
|
458 | 450 |
} |
459 | 451 |
|
460 | 452 |
logReplication.info("ReplicationHandler.handleSingleXMLDocument - Successfully replicated doc " + accNumber); |
... | ... | |
604 | 596 |
TypeMarshaller.unmarshalTypeFromStream( |
605 | 597 |
SystemMetadata.class, |
606 | 598 |
new ByteArrayInputStream(systemMetadataXML.getBytes("UTF-8"))); |
607 |
String guid = sysMeta.getIdentifier().getValue(); |
|
608 |
if (!IdentifierManager.getInstance().identifierExists(guid)) { |
|
609 |
logReplication.debug("Creating system metadata and guid/docid mapping for docid " + docinfoHash.get("docid") + " and guid: " + guid); |
|
610 |
IdentifierManager.getInstance().createMapping(guid, docinfoHash.get("docid")); |
|
611 |
IdentifierManager.getInstance().createSystemMetadata(sysMeta); |
|
612 |
} else { |
|
613 |
logReplication.debug("Updating guid/docid mapping for docid " + docinfoHash.get("docid") + " and guid: " + guid); |
|
614 |
IdentifierManager.getInstance().updateMapping(guid, docinfoHash.get("docid")); |
|
615 |
} |
|
616 |
IdentifierManager.getInstance().updateSystemMetadata(sysMeta); |
|
599 |
HazelcastService.getInstance().getSystemMetadataMap().put(sysMeta.getIdentifier(), sysMeta); |
|
617 | 600 |
} |
618 | 601 |
|
619 | 602 |
logReplication.info("ReplicationHandler.handleSingleDataFile - Successfully to write datafile " + accNumber); |
... | ... | |
840 | 823 |
SystemMetadata sysMeta = TypeMarshaller.unmarshalTypeFromStream(SystemMetadata.class, |
841 | 824 |
new ByteArrayInputStream(systemMetadataXML |
842 | 825 |
.getBytes("UTF-8"))); |
843 |
// String guid = sysMeta.getIdentifier().getValue(); |
|
844 |
if (!IdentifierManager.getInstance().identifierExists(guid)) { |
|
845 |
logReplication.debug("Creating system metadata for guid: " + guid); |
|
846 |
IdentifierManager.getInstance().createSystemMetadata(sysMeta); |
|
847 |
} |
|
848 |
IdentifierManager.getInstance().updateSystemMetadata(sysMeta); |
|
826 |
HazelcastService.getInstance().getSystemMetadataMap().put(sysMeta.getIdentifier(), sysMeta); |
|
849 | 827 |
} |
850 | 828 |
|
851 | 829 |
logReplication.info("ReplicationHandler.handleSystemMetadata - Successfully replicated system metadata for guid: " |
Also available in: Unified diff
rely on Hazelcast to store the SystemMetadata locally for the node. Entry event listeners store the shared system metadata on their local node when alerted. TODO: remove old replication code that included system metadata xml when replicating scimeta and data