Revision 7325
Added by ben leinfelder over 12 years ago
src/edu/ucsb/nceas/metacat/dataone/hazelcast/HazelcastService.java | ||
---|---|---|
216 | 216 |
identifiers = Hazelcast.getSet(identifiersSet); |
217 | 217 |
logMetacat.warn("Retrieved hzIdentifiers from Hazelcast"); |
218 | 218 |
|
219 |
// add any identifiers not already present |
|
220 |
Set<Identifier> idKeys = loadAllKeys(); |
|
221 |
//identifiers.addAll(idKeys); |
|
222 |
logMetacat.warn("Loading local keys into hzIdentifiers"); |
|
223 |
for (Identifier key: idKeys) { |
|
224 |
if (!identifiers.contains(key)) { |
|
225 |
logMetacat.debug("Adding missing hzIdentifiers key: " + key.getValue()); |
|
226 |
identifiers.add(key); |
|
227 |
} |
|
228 |
} |
|
229 |
logMetacat.warn("Initialized identifiers with local keys"); |
|
230 |
|
|
231 | 219 |
// Listen for changes to the system metadata map |
232 | 220 |
systemMetadata.addEntryListener(this, true); |
233 | 221 |
|
... | ... | |
498 | 486 |
} |
499 | 487 |
} |
500 | 488 |
|
501 |
/** |
|
502 |
* Make sure we have a copy of every entry in the shared map. |
|
503 |
* We use lazy loading and therefore the CNs may not all be in sync when one |
|
504 |
* comes back online after an extended period of being offline |
|
505 |
* This method is meant to retrieve shared SystemMetadata that does not exist locally. |
|
506 |
* A mak=jor shortcoming here is that if Hazelcast has assigned this node ownership of a PID |
|
507 |
* that does not exist on the local backing store, the SystemMetadata will be null. |
|
508 |
* @throws Exception |
|
509 |
* @deprecated |
|
510 |
*/ |
|
511 |
private void resynch() throws Exception { |
|
512 |
// loop through all the [shared] entries and save any missing ones locally |
|
513 |
List<String> localPids = IdentifierManager.getInstance().getAllSystemMetadataGUIDs(); |
|
514 |
logMetacat.warn("local pid count: " + localPids.size() + ", shared pid count: " + identifiers.size()); |
|
515 |
Iterator<Identifier> sharedPids = identifiers.iterator(); |
|
516 |
while (sharedPids.hasNext()) { |
|
517 |
Identifier pid = sharedPids.next(); |
|
518 |
logMetacat.trace("checking for shared pid locally: " + pid.getValue()); |
|
519 |
if (!localPids.contains(pid.getValue())) { |
|
520 |
logMetacat.warn("shared pid does not exist locally: " + pid.getValue()); |
|
521 |
SystemMetadata sm = systemMetadata.get(pid); |
|
522 |
if (sm != null) { |
|
523 |
// this may throw an exception if loading it to the shared map triggered entry updated events |
|
524 |
saveLocally(sm); |
|
525 |
} else { |
|
526 |
logMetacat.error("SystemMetadata for pid is null: " + pid.getValue()); |
|
527 |
Partition partition = hzInstance.getPartitionService().getPartition(pid); |
|
528 |
Member owner = partition.getOwner(); |
|
529 |
owner.localMember(); |
|
530 |
logMetacat.warn("owner of pid: " + pid.getValue() + " isLocal: " + owner.localMember() + " at " + owner.getInetSocketAddress().getAddress()); |
|
531 |
|
|
532 |
} |
|
533 |
} else { |
|
534 |
logMetacat.trace("shared pid already exisits locally: " + pid.getValue()); |
|
535 |
} |
|
536 |
} |
|
537 |
} |
|
538 | 489 |
|
539 | 490 |
/** |
540 | 491 |
* Make sure we have a copy of every entry in the shared map. |
... | ... | |
549 | 500 |
* @throws Exception |
550 | 501 |
*/ |
551 | 502 |
private void resynchToRemote() { |
503 |
|
|
504 |
// add any identifiers not already present |
|
505 |
Set<Identifier> idKeys = loadAllKeys(); |
|
506 |
//identifiers.addAll(idKeys); |
|
507 |
logMetacat.warn("Loading local keys into hzIdentifiers"); |
|
508 |
for (Identifier key: idKeys) { |
|
509 |
if (!identifiers.contains(key)) { |
|
510 |
logMetacat.debug("Adding missing hzIdentifiers key: " + key.getValue()); |
|
511 |
identifiers.add(key); |
|
512 |
} |
|
513 |
} |
|
514 |
logMetacat.warn("Initialized identifiers with local keys"); |
|
515 |
|
|
552 | 516 |
// loop through all the [shared] entries and save any missing ones locally |
553 |
List<String> localPids = IdentifierManager.getInstance().getAllSystemMetadataGUIDs(); |
|
554 |
logMetacat.warn("local pid count: " + localPids.size() + ", shared pid count: " + identifiers.size()); |
|
517 |
logMetacat.warn("local pid count: " + idKeys.size() + ", shared pid count: " + identifiers.size()); |
|
555 | 518 |
|
556 |
//loop through all the pids to find any nulls
|
|
519 |
//loop through all the pids to find any null SM that needs to be synched
|
|
557 | 520 |
Iterator<Identifier> sharedPids = identifiers.iterator(); |
558 | 521 |
while (sharedPids.hasNext()) { |
559 | 522 |
Identifier pid = sharedPids.next(); |
... | ... | |
562 | 525 |
if (sm == null) { |
563 | 526 |
logMetacat.warn("shared SystemMetadata for pid is null: " + pid.getValue()); |
564 | 527 |
// look up owner of the pid |
565 |
Partition partition = hzInstance.getPartitionService().getPartition(pid); |
|
566 |
Member owner = partition.getOwner(); |
|
567 |
boolean isLocalPid = owner.localMember(); |
|
568 |
logMetacat.debug("owner of pid: " + pid.getValue() + " isLocal: " + isLocalPid); |
|
528 |
// Partition partition = hzInstance.getPartitionService().getPartition(pid);
|
|
529 |
// Member owner = partition.getOwner();
|
|
530 |
// boolean isLocalPid = owner.localMember();
|
|
531 |
// logMetacat.debug("owner of pid: " + pid.getValue() + " isLocal: " + isLocalPid);
|
|
569 | 532 |
// if we don't own it, we can look it up locally in hopes that we have our own copy |
570 | 533 |
if (true) { |
571 | 534 |
// get directly from backing store |
Also available in: Unified diff
move the hzIdentifiers initialization into the resync thread so that it does not affect start up time. cleaned up unused methods and superfluous code.