Project

General

Profile

« Previous | Next » 

Revision 6435

handle entryAdded and entryUpdated the same - update the entry if it exists, otherwise create it

View differences:

CNodeService.java
880 880
	 */
881 881
	@Override
882 882
	public void entryAdded(EntryEvent<Identifier, SystemMetadata> event) {
883

  
884
		logMetacat.debug("Entry added to System Metadata map: " + event.getKey().getValue());
885
		PartitionService partitionService = Hazelcast.getPartitionService();
886
		Partition partition = partitionService.getPartition(event.getKey());
887
		Member ownerMember = partition.getOwner();
888
		if (!ownerMember.localMember()) {
889
			// need to pull the entry into the local store
890
			logMetacat.debug("Saving entry locally: " + event.getKey().getValue());
891
			try {
892
				if (!IdentifierManager.getInstance().identifierExists(event.getKey().getValue())) {
893
					IdentifierManager.getInstance().createSystemMetadata(event.getValue());
894
				} else {
895
					IdentifierManager.getInstance().updateSystemMetadata(event.getValue());
896
				}
897
			} catch (McdbDocNotFoundException e) {
898
				logMetacat.error(
899
						"Could not save System Metadata to local store.", e);
900
			}
901
		}
902

  
903
		// TODO evaluate the type of system metadata change, decide if it
904
		// warrants
905
		// a replication event, what type (DATA, METADATA, RESOURCE),
906
		// iteratively lock the PID, create and submit the tasks, and expect a
907
		// result back.
908
		// Deal with exceptions.
909
		boolean isMetadata = D1NodeService.isScienceMetadata(event.getValue());
910
		// TODO: do we need to do anything explicit here?
883
		// handle as update - that method will create if necessary
884
		entryUpdated(event);
911 885
	}
912 886

  
913 887
  /**
......
946 920
  @Override
947 921
  public void entryUpdated(EntryEvent<Identifier, SystemMetadata> event) {
948 922

  
949
    // TODO evaluate the type of system metadata change, decide if it warrants
950
    // a replication event, what type (DATA, METADATA, RESOURCE), 
951
    // iteratively lock the PID, create and submit the tasks, and expect a result back. 
952
    // Deal with exceptions.
923
		logMetacat.debug("Entry added/updated to System Metadata map: " + event.getKey().getValue());
924
		PartitionService partitionService = Hazelcast.getPartitionService();
925
		Partition partition = partitionService.getPartition(event.getKey());
926
		Member ownerMember = partition.getOwner();
927
		if (!ownerMember.localMember()) {
928
			// need to pull the entry into the local store
929
			logMetacat.debug("Saving entry locally: " + event.getKey().getValue());
930
			try {
931
				if (!IdentifierManager.getInstance().identifierExists(event.getKey().getValue())) {
932
					IdentifierManager.getInstance().createSystemMetadata(event.getValue());
933
				} else {
934
					IdentifierManager.getInstance().updateSystemMetadata(event.getValue());
935
				}
936
			} catch (McdbDocNotFoundException e) {
937
				logMetacat.error(
938
						"Could not save System Metadata to local store.", e);
939
			}
940
		}
941

  
942
		// TODO evaluate the type of system metadata change, decide if it
943
		// warrants a replication event, what type (DATA, METADATA, RESOURCE),
944
		// iteratively lock the PID, create and submit the tasks, and expect a
945
		// result back. Deal with exceptions.
946
		boolean isMetadata = D1NodeService.isScienceMetadata(event.getValue());
947
		// TODO: do we need to do anything explicit here?
953 948
    
954 949
  }
955 950

  

Also available in: Unified diff