Project

General

Profile

« Previous | Next » 

Revision 6409

Enable CNodeService to access 1) the hzNodes map defined in the DataONE process cluster by becoming a Hazelcast client (hzClient) to that cluster and 2) the hzSystemMetadata map defined in the DataONE storage cluster by becoming a member to that cluster (using direct Hazelcast calls). Added fields for maintaining the DataONE cluster properties.

View differences:

src/edu/ucsb/nceas/metacat/dataone/CNodeService.java
27 27
import java.util.List;
28 28

  
29 29
import org.apache.log4j.Logger;
30
import org.dataone.configuration.Settings;
30 31
import org.dataone.service.cn.v1.CNAuthorization;
31 32
import org.dataone.service.cn.v1.CNCore;
32 33
import org.dataone.service.cn.v1.CNRead;
......
42 43
import org.dataone.service.exceptions.ServiceFailure;
43 44
import org.dataone.service.types.v1.Checksum;
44 45
import org.dataone.service.types.v1.Identifier;
46
import org.dataone.service.types.v1.Node;
45 47
import org.dataone.service.types.v1.NodeList;
48
import org.dataone.service.types.v1.NodeReference;
46 49
import org.dataone.service.types.v1.ObjectFormat;
47 50
import org.dataone.service.types.v1.ObjectFormatIdentifier;
48 51
import org.dataone.service.types.v1.ObjectFormatList;
......
56 59
import org.dataone.service.types.v1.Subject;
57 60
import org.dataone.service.types.v1.SystemMetadata;
58 61

  
62
import com.hazelcast.client.HazelcastClient;
63
import com.hazelcast.core.Hazelcast;
64
import com.hazelcast.core.IMap;
65
import com.hazelcast.core.IQueue;
66

  
59 67
import edu.ucsb.nceas.metacat.EventLog;
60 68
import edu.ucsb.nceas.metacat.IdentifierManager;
61 69
import edu.ucsb.nceas.metacat.McdbDocNotFoundException;
70
import edu.ucsb.nceas.metacat.properties.PropertyService;
62 71
import edu.ucsb.nceas.metacat.replication.ForceReplicationSystemMetadataHandler;
72
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
63 73

  
64 74
/**
65 75
 * Represents Metacat's implementation of the DataONE Coordinating Node 
......
74 84
	/* the instance of the CNodeService object */
75 85
  private static CNodeService instance = null;
76 86
  
87
  /* The instance of the Hazelcast client */
88
  private HazelcastClient hzClient;
89

  
90
  /* The name of the DataONE Hazelcast cluster group */
91
  private String groupName;
92

  
93
  /* The name of the DataONE Hazelcast cluster password */
94
  private String groupPassword;
95
  
96
  /* The name of the DataONE Hazelcast cluster IP addresses */
97
  private String addressList;
98
  
99
  /* The name of the node map */
100
  private String nodeMap;
101

  
102
  /* The name of the system metadata map */
103
  private String systemMetadataMap;
104
  
105
  /* The Hazelcast distributed task id generator namespace */
106
  private String taskIds;
107
  
108
  /* The Hazelcast distributed system metadata map */
109
  private IMap<NodeReference, Node> nodes;
110

  
111
  /* The Hazelcast distributed system metadata map */
112
  private IMap<Identifier, SystemMetadata> systemMetadata;
113

  
77 114
  /* the logger instance */
78 115
  private Logger logMetacat = null;
79 116

  
......
96 133
  private CNodeService() {
97 134
  	super();
98 135
    logMetacat = Logger.getLogger(CNodeService.class);
136
    
137
    // Get configuration properties on instantiation
138
    try {
139
	    groupName = 
140
	      PropertyService.getProperty("dataone.hazelcast.processCluster.groupName");
141
	    groupPassword = 
142
	    	PropertyService.getProperty("dataone.hazelcast.processCluster.password");
143
	    addressList = 
144
	    	PropertyService.getProperty("dataone.hazelcast.processCluster.instances");
145
	    nodeMap = 
146
	    	PropertyService.getProperty("dataone.hazelcast.processCluster.nodesMap");
147
	    systemMetadataMap = 
148
	    	PropertyService.getProperty("dataone.hazelcast.storageCluster.systemMetadata");
149
	    taskIds = 
150
	    	PropertyService.getProperty("dataone.hazelcast.storageCluster.tasksIdGenerator");
151
	    
152
	    // Become a DataONE-process cluster client
153
	    String[] addresses = addressList.split(",");
154
	    hzClient = 
155
	      HazelcastClient.newHazelcastClient(this.groupName, this.groupPassword, addresses);
156
	    nodes = hzClient.getMap(nodeMap);
157

  
158
      // Get a reference to the shared system metadata map as a cluster member
159
	    systemMetadata = Hazelcast.getMap(systemMetadataMap);
160

  
161
    } catch (PropertyNotFoundException e) {
162

  
163
    	String msg = "Couldn't find Hazelcast properties for the DataONE clusters. " +
164
    	  "The error message was: " + e.getMessage();
165
    	logMetacat.error(msg);
166
    	
167
    }
168

  
99 169
        
100 170
  }
101 171
    
......
168 238
	 */
169 239
	@Override
170 240
	public boolean setReplicationStatus(Session session, Identifier pid,
171
	  ReplicationStatus status) 
241
	  NodeReference targetNode, ReplicationStatus status) 
172 242
	  throws ServiceFailure, NotImplemented, InvalidToken, NotAuthorized, 
173 243
	  InvalidRequest, NotFound {
174 244

  
......
746 816
	 * @throws NotFound
747 817
	 */
748 818
	@Override
749
  public boolean isReplicationAuthorized(Session originatingNodeSession, 
819
  public boolean isNodeAuthorized(Session originatingNodeSession, 
750 820
    Subject targetNodeSubject, Identifier pid, Permission replicatePermission) 
751 821
	  throws NotImplemented, NotAuthorized, InvalidToken, ServiceFailure, 
752 822
	  NotFound, InvalidRequest {

Also available in: Unified diff