Revision 7344
Added by ben leinfelder over 12 years ago
src/edu/ucsb/nceas/metacat/dataone/hazelcast/HazelcastService.java | ||
---|---|---|
663 | 663 |
public void itemAdded(Identifier pid) { |
664 | 664 |
// publish the SM for the pid if we have it locally |
665 | 665 |
logMetacat.debug("Responding to itemAdded for pid: " + pid.getValue()); |
666 |
|
|
667 |
// lock this event, only if we have a local copy to contribute |
|
666 | 668 |
ILock lock = null; |
667 | 669 |
try { |
668 |
lock = hzInstance.getLock(MISSING_PID_PREFIX + pid.getValue()); |
|
669 |
|
|
670 |
if ( lock.tryLock() ) { |
|
671 |
// look up the local copy of the SM |
|
672 |
SystemMetadata sm = IdentifierManager.getInstance().getSystemMetadata(pid.getValue()); |
|
673 |
if (sm != null) { |
|
674 |
// "publish" the system metadata to the shared map since it showed up on the missing queue |
|
675 |
logMetacat.debug("Adding SystemMetadata to shared map for pid: " + pid.getValue()); |
|
676 |
systemMetadata.put(pid, sm); |
|
677 |
|
|
678 |
// remove the entry since we processed it |
|
679 |
missingIdentifiers.remove(pid); |
|
680 |
|
|
681 |
} else { |
|
682 |
logMetacat.warn("Local SystemMetadata was null for pid: " + pid.getValue()); |
|
683 |
|
|
684 |
} |
|
685 |
|
|
686 |
} else { |
|
687 |
logMetacat.debug(MISSING_PID_PREFIX + pid.getValue() + " was already locked. Skipping."); |
|
688 |
|
|
689 |
} |
|
690 |
|
|
670 |
// look up the local copy of the SM |
|
671 |
SystemMetadata sm = IdentifierManager.getInstance().getSystemMetadata(pid.getValue()); |
|
672 |
if (sm != null) { |
|
673 |
lock = hzInstance.getLock(MISSING_PID_PREFIX + pid.getValue()); |
|
674 |
|
|
675 |
if ( lock.tryLock() ) { |
|
676 |
// "publish" the system metadata to the shared map since it showed up on the missing queue |
|
677 |
logMetacat.debug("Adding SystemMetadata to shared map for pid: " + pid.getValue()); |
|
678 |
systemMetadata.put(pid, sm); |
|
679 |
|
|
680 |
// remove the entry since we processed it |
|
681 |
missingIdentifiers.remove(pid); |
|
682 |
|
|
683 |
} else { |
|
684 |
logMetacat.debug(MISSING_PID_PREFIX + pid.getValue() + " was already locked. Skipping."); |
|
685 |
} |
|
686 |
} else { |
|
687 |
// can't help here |
|
688 |
logMetacat.warn("Local system metadata not found for pid: " + pid.getValue()); |
|
689 |
} |
|
691 | 690 |
} catch (Exception e) { |
692 | 691 |
logMetacat.error("Error looking up missing system metadata for pid: " + pid.getValue()); |
693 |
|
|
694 | 692 |
} finally { |
695 |
if ( lock != null ) {
|
|
696 |
lock.unlock();
|
|
697 |
|
|
693 |
if ( lock != null ) {
|
|
694 |
lock.unlock();
|
|
695 |
} |
|
698 | 696 |
} |
699 |
} |
|
700 |
|
|
701 | 697 |
} |
702 | 698 |
|
703 | 699 |
/** |
Also available in: Unified diff
only lock the missing pid event if we know we have it locally to contribute.
https://redmine.dataone.org/issues/3117