Project

General

Profile

« Previous | Next » 

Revision 6411

Added by Chris Jones over 13 years ago

Add stub methods in CNodeService that implement the Hazelcast EntryListener interface: entryAdded(), entryRemoved(), entryUpdated(), and entryEvicted(). Add a listener to the hzSystemMetadata map so the CNodeService can respond to those events and create appropriate CNReplicationTask objects for distributed execution across the CN cluster. Again, stubs only so far.

View differences:

src/edu/ucsb/nceas/metacat/dataone/CNodeService.java
60 60
import org.dataone.service.types.v1.SystemMetadata;
61 61

  
62 62
import com.hazelcast.client.HazelcastClient;
63
import com.hazelcast.core.EntryEvent;
64
import com.hazelcast.core.EntryListener;
63 65
import com.hazelcast.core.Hazelcast;
64 66
import com.hazelcast.core.IMap;
65 67
import com.hazelcast.core.IQueue;
......
79 81
 *
80 82
 */
81 83
public class CNodeService extends D1NodeService implements CNAuthorization,
82
    CNCore, CNRead, CNReplication {
84
    CNCore, CNRead, CNReplication, EntryListener<Identifier, SystemMetadata> {
83 85

  
84 86
  /* the instance of the CNodeService object */
85 87
  private static CNodeService instance = null;
......
158 160
      // Get a reference to the shared system metadata map as a cluster member
159 161
      systemMetadata = Hazelcast.getMap(systemMetadataMap);
160 162

  
163
      // Listen for changes to the system metadata map
164
      systemMetadata.addEntryListener(this, true);
165
      
161 166
    } catch (PropertyNotFoundException e) {
162 167

  
163 168
      String msg = "Couldn't find Hazelcast properties for the DataONE clusters. " +
......
825 830
    
826 831
  }
827 832

  
833
  /**
834
   * Implement the EntryListener interface for Hazelcast, reponding to entry
835
   * added events in the hzSystemMetadata map.  Evaluate the entry and create
836
   * CNReplicationTasks as appropriate (for DATA, METADATA, RESOURCE)
837
   * 
838
   * @param event - The EntryEvent that occurred
839
   */
840
  @Override
841
  public void entryAdded(EntryEvent<Identifier, SystemMetadata> event) {
842

  
843
    // TODO evaluate the type of system metadata change, decide if it warrants
844
    // a replication event, what type (DATA, METADATA, RESOURCE), 
845
    // iteratively lock the PID, create and submit the tasks, and expect a result back. 
846
    // Deal with exceptions.
847
    
848
  }
849

  
850
  /**
851
   * Implement the EntryListener interface for Hazelcast, reponding to entry
852
   * evicted events in the hzSystemMetadata map.  Evaluate the entry and create
853
   * CNReplicationTasks as appropriate (for DATA, METADATA, RESOURCE)
854
   * 
855
   * @param event - The EntryEvent that occurred
856
   */
857
  @Override
858
  public void entryEvicted(EntryEvent<Identifier, SystemMetadata> event) {
859
    // nothing to do, entries are still in the backing store
860
    
861
  }
862

  
863
  /**
864
   * Implement the EntryListener interface for Hazelcast, reponding to entry
865
   * removed events in the hzSystemMetadata map.  Evaluate the entry and create
866
   * CNReplicationTasks as appropriate (for DATA, METADATA, RESOURCE)
867
   * 
868
   * @param event - The EntryEvent that occurred
869
   */
870
  @Override
871
  public void entryRemoved(EntryEvent<Identifier, SystemMetadata> event) {
872
    // we don't remove objects
873
    
874
  }
875

  
876
  /**
877
   * Implement the EntryListener interface for Hazelcast, reponding to entry
878
   * updated 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 entryUpdated(EntryEvent<Identifier, SystemMetadata> event) {
885

  
886
    // TODO evaluate the type of system metadata change, decide if it warrants
887
    // a replication event, what type (DATA, METADATA, RESOURCE), 
888
    // iteratively lock the PID, create and submit the tasks, and expect a result back. 
889
    // Deal with exceptions.
890
    
891
  }
892

  
828 893
}

Also available in: Unified diff