Revision 7421
Added by Chris Jones about 12 years ago
src/edu/ucsb/nceas/metacat/dataone/hazelcast/HazelcastService.java | ||
---|---|---|
89 | 89 |
/* The Hazelcast configuration */ |
90 | 90 |
private Config hzConfig; |
91 | 91 |
|
92 |
/* The instance of the Hazelcast client */ |
|
93 |
// private HazelcastClient hzClient; |
|
94 |
|
|
95 |
/* The name of the DataONE Hazelcast cluster group */ |
|
96 |
private String groupName; |
|
97 |
|
|
98 |
/* The name of the DataONE Hazelcast cluster password */ |
|
99 |
private String groupPassword; |
|
100 |
|
|
101 |
/* The name of the DataONE Hazelcast cluster IP addresses */ |
|
102 |
private String addressList; |
|
103 |
|
|
104 |
/* The name of the node map */ |
|
105 |
private String nodeMap; |
|
106 |
|
|
107 | 92 |
/* The name of the system metadata map */ |
108 | 93 |
private String systemMetadataMap; |
109 | 94 |
|
110 |
/* The Hazelcast distributed task id generator namespace */ |
|
111 |
private String taskIds; |
|
112 |
|
|
113 |
/* The Hazelcast distributed node map */ |
|
114 |
private IMap<NodeReference, Node> nodes; |
|
115 |
|
|
116 | 95 |
/* The Hazelcast distributed system metadata map */ |
117 | 96 |
private IMap<Identifier, SystemMetadata> systemMetadata; |
118 | 97 |
|
... | ... | |
171 | 150 |
logMetacat.debug("HazelcastService.init() called."); |
172 | 151 |
|
173 | 152 |
String configFileName = null; |
174 |
Config config = null; |
|
175 | 153 |
try { |
176 | 154 |
configFileName = PropertyService.getProperty("dataone.hazelcast.configFilePath"); |
177 |
config = new FileSystemXmlConfig(configFileName);
|
|
155 |
hzConfig = new FileSystemXmlConfig(configFileName);
|
|
178 | 156 |
} catch (Exception e) { |
179 | 157 |
configFileName = PropertyService.CONFIG_FILE_DIR + FileUtil.getFS() + "hazelcast.xml"; |
180 | 158 |
logMetacat.warn("Custom Hazelcast configuration not defined, using default: " + configFileName); |
181 | 159 |
// make sure we have the config |
182 | 160 |
try { |
183 |
config = new FileSystemXmlConfig(configFileName);
|
|
161 |
hzConfig = new FileSystemXmlConfig(configFileName);
|
|
184 | 162 |
} catch (FileNotFoundException e1) { |
185 | 163 |
String msg = e.getMessage(); |
186 | 164 |
logMetacat.error(msg); |
... | ... | |
188 | 166 |
} |
189 | 167 |
} |
190 | 168 |
|
191 |
Hazelcast.init(config); |
|
192 |
this.hzInstance = Hazelcast.getDefaultInstance(); |
|
169 |
this.hzInstance = Hazelcast.newHazelcastInstance(hzConfig); |
|
193 | 170 |
|
194 | 171 |
logMetacat.debug("Initialized hzInstance"); |
195 | 172 |
|
196 | 173 |
// Get configuration properties on instantiation |
197 | 174 |
try { |
198 |
groupName = |
|
199 |
PropertyService.getProperty("dataone.hazelcast.processCluster.groupName"); |
|
200 |
groupPassword = |
|
201 |
PropertyService.getProperty("dataone.hazelcast.processCluster.password"); |
|
202 |
addressList = |
|
203 |
PropertyService.getProperty("dataone.hazelcast.processCluster.instances"); |
|
204 | 175 |
systemMetadataMap = |
205 | 176 |
PropertyService.getProperty("dataone.hazelcast.storageCluster.systemMetadataMap"); |
206 | 177 |
identifiersSet = PropertyService.getProperty("dataone.hazelcast.storageCluster.identifiersSet"); |
207 |
// nodeMap = |
|
208 |
// PropertyService.getProperty("dataone.hazelcast.processCluster.nodesMap"); |
|
209 |
// Become a DataONE-process cluster client |
|
210 |
// String[] addresses = addressList.split(","); |
|
211 |
// hzClient = |
|
212 |
// HazelcastClient.newHazelcastClient(this.groupName, this.groupPassword, addresses); |
|
213 |
// nodes = hzClient.getMap(nodeMap); |
|
214 |
|
|
178 |
|
|
215 | 179 |
// Get a reference to the shared system metadata map as a cluster member |
216 | 180 |
// NOTE: this loads the map from the backing store and can take a long time for large collections |
217 |
systemMetadata = Hazelcast.getMap(systemMetadataMap);
|
|
181 |
systemMetadata = this.hzInstance.getMap(systemMetadataMap);
|
|
218 | 182 |
|
219 | 183 |
logMetacat.debug("Initialized systemMetadata"); |
220 | 184 |
|
221 | 185 |
// Get a reference to the shared identifiers set as a cluster member |
222 | 186 |
// NOTE: this takes a long time to complete |
223 | 187 |
logMetacat.warn("Retrieving hzIdentifiers from Hazelcast"); |
224 |
identifiers = Hazelcast.getSet(identifiersSet);
|
|
188 |
identifiers = this.hzInstance.getSet(identifiersSet);
|
|
225 | 189 |
logMetacat.warn("Retrieved hzIdentifiers from Hazelcast"); |
226 | 190 |
|
227 | 191 |
// for publishing the "PIDs Wanted" list |
228 |
missingIdentifiers = Hazelcast.getSet("hzMissingIdentifiersSet");
|
|
192 |
missingIdentifiers = this.hzInstance.getSet("hzMissingIdentifiersSet");
|
|
229 | 193 |
|
230 | 194 |
missingIdentifiers.addItemListener(this, true); |
231 | 195 |
|
... | ... | |
331 | 295 |
*/ |
332 | 296 |
public void stop() throws ServiceException { |
333 | 297 |
|
334 |
Hazelcast.getLifecycleService().shutdown();
|
|
298 |
this.hzInstance.getLifecycleService().shutdown();
|
|
335 | 299 |
|
336 | 300 |
} |
337 | 301 |
|
... | ... | |
347 | 311 |
protected void doRefresh() throws ServiceException { |
348 | 312 |
|
349 | 313 |
// TODO: verify that the correct config file is still used |
350 |
Hazelcast.getLifecycleService().restart();
|
|
314 |
this.hzInstance.getLifecycleService().restart();
|
|
351 | 315 |
|
352 | 316 |
} |
353 | 317 |
|
... | ... | |
423 | 387 |
public void entryUpdated(EntryEvent<Identifier, SystemMetadata> event) { |
424 | 388 |
|
425 | 389 |
logMetacat.debug("Entry added/updated to System Metadata map: " + event.getKey().getValue()); |
426 |
PartitionService partitionService = Hazelcast.getPartitionService();
|
|
390 |
PartitionService partitionService = this.hzInstance.getPartitionService();
|
|
427 | 391 |
Partition partition = partitionService.getPartition(event.getKey()); |
428 | 392 |
Member ownerMember = partition.getOwner(); |
429 | 393 |
SystemMetadata sysmeta = event.getValue(); |
Also available in: Unified diff
In migrating to Hazelcast 2.4.x, replace deprecated methods. Use Hazelcast.newHazelcastInstance() rather than Hazelcast.init(). For other deprecated static methods, use the HazelcastInstance equivalent calls.