Project

General

Profile

« Previous | Next » 

Revision 6447

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

View differences:

src/edu/ucsb/nceas/metacat/MetacatHandler.java
106 106
import edu.ucsb.nceas.metacat.client.InsufficientKarmaException;
107 107
import edu.ucsb.nceas.metacat.database.DBConnection;
108 108
import edu.ucsb.nceas.metacat.database.DBConnectionPool;
109
import edu.ucsb.nceas.metacat.dataone.hazelcast.HazelcastService;
109 110
import edu.ucsb.nceas.metacat.dataquery.DataQuery;
110 111
import edu.ucsb.nceas.metacat.dataquery.MetacatDatabaseConnectionPoolFactory;
111 112
import edu.ucsb.nceas.metacat.event.MetacatDocumentEvent;
......
1857 1858
                  // handle inserts
1858 1859
                  try {
1859 1860
                    sysMeta = createSystemMetadata(newdocid, user, groups);
1860
                    IdentifierManager.getInstance().createSystemMetadata(sysMeta);
1861
                    HazelcastService.getInstance().getSystemMetadataMap().put(sysMeta.getIdentifier(), sysMeta);
1861 1862
                    
1862 1863
                  } catch ( McdbDocNotFoundException dnfe ) {
1863 1864
                    logMetacat.debug(
......
3001 3002
                            SystemMetadata sm = createSystemMetadata(docid, username, groupnames);
3002 3003
							
3003 3004
					        // manage it in the store
3004
					        if (IdentifierManager.getInstance().identifierExists(docid)) {
3005
						        IdentifierManager.getInstance().createSystemMetadata(sm);
3006
					        } else {
3007
						        IdentifierManager.getInstance().updateSystemMetadata(sm);
3008
					        }
3005
                            HazelcastService.getInstance().getSystemMetadataMap().put(sm.getIdentifier(), sm);
3009 3006
                 
3010 3007
					        
3011 3008
                        } catch (Exception ee) {
src/edu/ucsb/nceas/metacat/dataone/CNodeService.java
537 537
        logMetacat.debug("Starting to insert SystemMetadata...");
538 538
        sysmeta.setDateSysMetadataModified(new Date());
539 539
        try {
540
          IdentifierManager.getInstance().createSystemMetadata(sysmeta);
541
          // force replication of this record
542
          ForceReplicationSystemMetadataHandler forceReplication = 
543
            new ForceReplicationSystemMetadataHandler(guid.getValue(), null);
540
        	HazelcastService.getInstance().getSystemMetadataMap().put(sysmeta.getIdentifier(), sysmeta);
544 541
        } catch (Exception e) {
545 542
            throw new ServiceFailure("4862", "Error inserting system metadata: " + e.getClass() + ": " + e.getMessage());
546 543
        }
src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java
76 76
import edu.ucsb.nceas.metacat.IdentifierManager;
77 77
import edu.ucsb.nceas.metacat.McdbDocNotFoundException;
78 78
import edu.ucsb.nceas.metacat.MetacatHandler;
79
import edu.ucsb.nceas.metacat.dataone.hazelcast.HazelcastService;
79 80
import edu.ucsb.nceas.metacat.properties.PropertyService;
80 81
import edu.ucsb.nceas.metacat.replication.ForceReplicationHandler;
81 82
import edu.ucsb.nceas.metacat.util.SystemUtil;
......
241 242
    }
242 243

  
243 244
    // save the sysmeta
244
    try {
245
		IdentifierManager.getInstance().createSystemMetadata(sysmeta);
246
	} catch (McdbDocNotFoundException e) {
247
	    throw new ServiceFailure("1190", "Unable to save System Metadata for the object. ");
248
	}
245
    HazelcastService.getInstance().getSystemMetadataMap().put(sysmeta.getIdentifier(), sysmeta);
249 246
    
250 247
    // setting the resulting identifier failed
251 248
    if (localId == null ) {
......
946 943
        sysmeta.getDateSysMetadataModified());
947 944

  
948 945
    //insert the system metadata
949
	try {
950
		IdentifierManager.getInstance().createSystemMetadata(sysmeta);
951
	  
952
	} catch (McdbDocNotFoundException e) {
953
      throw new ServiceFailure("1030", "Error inserting system metadata: " + 
954
      	e.getClass() + ": " + e.getMessage());
946
    HazelcastService.getInstance().getSystemMetadataMap().put(sysmeta.getIdentifier(), sysmeta);
955 947
      
956
    }
957
      
958 948
  }
959 949

  
960 950
  /**
src/edu/ucsb/nceas/metacat/replication/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: "
src/edu/ucsb/nceas/metacat/replication/ReplicationService.java
78 78
import edu.ucsb.nceas.metacat.database.DBConnection;
79 79
import edu.ucsb.nceas.metacat.database.DBConnectionPool;
80 80
import edu.ucsb.nceas.metacat.database.DatabaseService;
81
import edu.ucsb.nceas.metacat.dataone.hazelcast.HazelcastService;
81 82
import edu.ucsb.nceas.metacat.properties.PropertyService;
82 83
import edu.ucsb.nceas.metacat.shared.BaseService;
83 84
import edu.ucsb.nceas.metacat.shared.HandlerException;
......
589 590
					TypeMarshaller.unmarshalTypeFromStream(
590 591
							SystemMetadata.class,
591 592
							new ByteArrayInputStream(systemMetadataXML.getBytes("UTF-8")));
592
				String guid = sysMeta.getIdentifier().getValue();
593
				if (!IdentifierManager.getInstance().identifierExists(guid)) {
594
					logReplication.debug("Creating system metadata and guid/docid mapping for docid "
595
									+ docinfoHash.get("docid")
596
									+ " and guid: "
597
									+ guid);
598
					IdentifierManager.getInstance().createMapping(guid, docinfoHash.get("docid"));
599
					IdentifierManager.getInstance().createSystemMetadata(sysMeta);
600
				} else {
601
					logReplication.debug("Updating guid/docid mapping for docid "
602
									+ docinfoHash.get("docid") + " and guid: "
603
									+ guid);
604
					IdentifierManager.getInstance().updateMapping(guid, docinfoHash.get("docid"));
605
				}
606
				IdentifierManager.getInstance().updateSystemMetadata(sysMeta);
593
				HazelcastService.getInstance().getSystemMetadataMap().put(sysMeta.getIdentifier(), sysMeta);
607 594
			}
608 595
      
609 596
        	// replicate doc contents
......
870 857
		      		TypeMarshaller.unmarshalTypeFromStream(
871 858
		      				  SystemMetadata.class, 
872 859
		      				  new ByteArrayInputStream(systemMetadataXML.getBytes("UTF-8")));
873
		      	  String guid = sysMeta.getIdentifier().getValue();
874
		      	  if (!IdentifierManager.getInstance().identifierExists(guid)) {
875
		      		  logReplication.debug("Creating system metadata and guid/docid mapping for docid " + docinfoHash.get("docid") + " and guid: " + guid);
876
		      		  IdentifierManager.getInstance().createMapping(guid, docinfoHash.get("docid"));
877
		      		  IdentifierManager.getInstance().createSystemMetadata(sysMeta);
878
		      	  } else {
879
		      		  logReplication.debug("Updating guid/docid mapping for docid " + docinfoHash.get("docid") + " and guid: " + guid);
880
		      		  IdentifierManager.getInstance().updateMapping(guid, docinfoHash.get("docid"));
881
		      	  }
882
		      	  IdentifierManager.getInstance().updateSystemMetadata(sysMeta);
860
		      	  HazelcastService.getInstance().getSystemMetadataMap().put(sysMeta.getIdentifier(), sysMeta);
883 861
		        }
884 862

  
885 863
				if (writeException != null) {
......
1081 1059
					TypeMarshaller.unmarshalTypeFromStream(
1082 1060
							SystemMetadata.class,
1083 1061
							new ByteArrayInputStream(systemMetadataXML.getBytes("UTF-8")));
1084
				if (!IdentifierManager.getInstance().identifierExists(guid)) {
1085
					logReplication.debug("Creating system metadata for guid: " + guid);
1086
					IdentifierManager.getInstance().createSystemMetadata(sysMeta);
1087
				}
1088
				IdentifierManager.getInstance().updateSystemMetadata(sysMeta);
1062
				HazelcastService.getInstance().getSystemMetadataMap().put(sysMeta.getIdentifier(), sysMeta);
1089 1063
			}
1090 1064
      
1091 1065
			logReplication.info("ReplicationService.handleForceReplicateSystemMetadataRequest - processed guid: " + guid);

Also available in: Unified diff