Project

General

Profile

« Previous | Next » 

Revision 6434

handle entryAdded (to hzSystemMetadata) to store sysmeta to local store when it is not already present

View differences:

src/edu/ucsb/nceas/metacat/dataone/CNodeService.java
28 28
import java.util.Set;
29 29

  
30 30
import org.apache.log4j.Logger;
31
import org.dataone.configuration.Settings;
32 31
import org.dataone.service.cn.v1.CNAuthorization;
33 32
import org.dataone.service.cn.v1.CNCore;
34 33
import org.dataone.service.cn.v1.CNRead;
......
65 64
import com.hazelcast.core.EntryListener;
66 65
import com.hazelcast.core.Hazelcast;
67 66
import com.hazelcast.core.IMap;
68
import com.hazelcast.core.IQueue;
69 67
import com.hazelcast.core.Member;
70 68
import com.hazelcast.partition.Partition;
71 69
import com.hazelcast.partition.PartitionService;
......
874 872
  }
875 873

  
876 874
  /**
877
   * Implement the EntryListener interface for Hazelcast, reponding to entry
878
   * added events in the hzSystemMetadata map.  Evaluate the entry and create
879
   * CNReplicationTasks as appropriate (for DATA, METADATA, RESOURCE)
880
   * 
881
   * @param event - The EntryEvent that occurred
882
   */
883
  @Override
884
  public void entryAdded(EntryEvent<Identifier, SystemMetadata> event) {
875
	 * Implement the EntryListener interface for Hazelcast, reponding to entry
876
	 * added events in the hzSystemMetadata map. Evaluate the entry and create
877
	 * CNReplicationTasks as appropriate (for DATA, METADATA, RESOURCE)
878
	 * 
879
	 * @param event - The EntryEvent that occurred
880
	 */
881
	@Override
882
	public void entryAdded(EntryEvent<Identifier, SystemMetadata> event) {
885 883

  
886
	  logMetacat.debug("Entry added to System Metadata map: " + event.getKey().getValue());
887
	  PartitionService partitionService = Hazelcast.getPartitionService();
888
	  Partition partition = partitionService.getPartition(event.getKey());
889
	  Member ownerMember = partition.getOwner();
890
	  if (!ownerMember.localMember()) {
891
		  // need to pull the entry into the local store
892
		  logMetacat.debug("Saving entry locally: " + event.getKey().getValue());
893
		  try {
894
			IdentifierManager.getInstance().createSystemMetadata(event.getValue());
895
		} catch (McdbDocNotFoundException e) {
896
			// TODO Auto-generated catch block
897
			e.printStackTrace();
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
			}
898 901
		}
899
	  }
900
	  
901
    // TODO evaluate the type of system metadata change, decide if it warrants
902
    // a replication event, what type (DATA, METADATA, RESOURCE), 
903
    // iteratively lock the PID, create and submit the tasks, and expect a result back. 
904
    // Deal with exceptions.
905
    
906
  }
907 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?
911
	}
912

  
908 913
  /**
909 914
   * Implement the EntryListener interface for Hazelcast, reponding to entry
910 915
   * evicted events in the hzSystemMetadata map.  Evaluate the entry and create
src/edu/ucsb/nceas/metacat/dataone/hazelcast/SystemMetadataMap.java
40 40
	@Override
41 41
	public void store(Identifier pid, SystemMetadata sm) {
42 42
		try {
43
			//System.out.println("Storing System Metadata to store: " + pid.getValue());
43 44
			if (!IdentifierManager.getInstance().identifierExists(pid.getValue())) {
44 45
				IdentifierManager.getInstance().createSystemMetadata(sm);
45 46
			} else {

Also available in: Unified diff