Revision 7514
Added by Chris Jones almost 12 years ago
src/edu/ucsb/nceas/metacat/dataone/CNodeService.java | ||
---|---|---|
676 | 676 |
} |
677 | 677 |
|
678 | 678 |
targetReplica.setReplicationStatus(status); |
679 |
targetReplica.setReplicaVerified(Calendar.getInstance().getTime()); |
|
679 |
|
|
680 | 680 |
logMetacat.debug("Set the replication status for " + |
681 | 681 |
targetReplica.getReplicaMemberNode().getValue() + " to " + |
682 | 682 |
targetReplica.getReplicationStatus() + " for identifier " + |
... | ... | |
716 | 716 |
" on target node " + targetNode + ". The exception was: " + |
717 | 717 |
failure.getMessage()); |
718 | 718 |
} |
719 |
|
|
720 |
// update the replica nodes about the completed replica when complete |
|
721 |
if (status == ReplicationStatus.COMPLETED) { |
|
722 |
broadcastSystemMetadataChange(systemMetadata); |
|
723 |
} |
|
724 |
|
|
719 | 725 |
} catch (RuntimeException e) { |
720 | 726 |
throw new ServiceFailure("4700", e.getMessage()); |
721 | 727 |
|
... | ... | |
735 | 741 |
return true; |
736 | 742 |
} |
737 | 743 |
|
738 |
/** |
|
744 |
/* |
|
745 |
* Inform each replica node that system metadata has changed |
|
746 |
* |
|
747 |
* @param systemMetadata the system metadata object with the replica list |
|
748 |
*/ |
|
749 |
private void broadcastSystemMetadataChange(SystemMetadata systemMetadata) { |
|
750 |
|
|
751 |
CNode cn = null; |
|
752 |
NodeList nodeList = new NodeList(); |
|
753 |
List<Node> nodes = new ArrayList<Node>(); |
|
754 |
|
|
755 |
List<Replica> replicaList = systemMetadata.getReplicaList(); |
|
756 |
|
|
757 |
// get the node list so we know the node type |
|
758 |
try { |
|
759 |
cn = D1Client.getCN(); |
|
760 |
nodeList = cn.listNodes(); |
|
761 |
nodes = nodeList.getNodeList(); |
|
762 |
|
|
763 |
// iterate through the replica list and inform each MN of the system metadata change |
|
764 |
for (Replica replica : replicaList) { |
|
765 |
NodeReference nodeId = replica.getReplicaMemberNode(); |
|
766 |
try { |
|
767 |
for (Node node : nodes) { |
|
768 |
if (node.getIdentifier() == nodeId) { |
|
769 |
if ( node.getType() == NodeType.MN) { |
|
770 |
MNode replicaNode = D1Client.getMN(nodeId); |
|
771 |
// call MN.systemMetadataChanged(); |
|
772 |
replicaNode.systemMetadataChanged(getSession(), |
|
773 |
systemMetadata.getIdentifier(), |
|
774 |
systemMetadata.getSerialVersion().longValue(), |
|
775 |
systemMetadata.getDateSysMetadataModified()); |
|
776 |
if (logMetacat.isDebugEnabled()) { |
|
777 |
logMetacat.debug("Called systemMetadataChanged() for identifier " + |
|
778 |
systemMetadata.getIdentifier().getValue() + |
|
779 |
" for node " + nodeId.getValue()); |
|
780 |
} |
|
781 |
} |
|
782 |
} |
|
783 |
} |
|
784 |
|
|
785 |
} catch (BaseException e) { |
|
786 |
logMetacat.error("Couldn't contact " + nodeId.getValue() + |
|
787 |
" to inform it of the system metadata change for identifier " + |
|
788 |
systemMetadata.getIdentifier().getValue()); |
|
789 |
} |
|
790 |
} |
|
791 |
|
|
792 |
} catch (BaseException e1) { |
|
793 |
logMetacat.error("Couldn't get the node list from the CN to broadcast the system " + |
|
794 |
"metadata change for identifier " + systemMetadata.getIdentifier().getValue()); |
|
795 |
} |
|
796 |
|
|
797 |
|
|
798 |
} |
|
799 |
|
|
800 |
/** |
|
739 | 801 |
* Return the checksum of the object given the identifier |
740 | 802 |
* |
741 | 803 |
* @param session - the Session object containing the credentials for the Subject |
... | ... | |
1528 | 1590 |
systemMetadata.setSerialVersion(systemMetadata.getSerialVersion().add(BigInteger.ONE)); |
1529 | 1591 |
systemMetadata.setDateSysMetadataModified(Calendar.getInstance().getTime()); |
1530 | 1592 |
HazelcastService.getInstance().getSystemMetadataMap().put(systemMetadata.getIdentifier(), systemMetadata); |
1531 |
|
|
1593 |
|
|
1594 |
// inform replica nodes of the change if the status is complete |
|
1595 |
if ( replicaStatus == ReplicationStatus.COMPLETED ) { |
|
1596 |
broadcastSystemMetadataChange(systemMetadata); |
|
1597 |
|
|
1598 |
} |
|
1532 | 1599 |
} catch (RuntimeException e) { |
1533 | 1600 |
logMetacat.info("Unknown RuntimeException thrown: " + e.getCause().getMessage()); |
1534 | 1601 |
throw new ServiceFailure("4852", e.getMessage()); |
Also available in: Unified diff
To keep all nodes up to date with regard to system metadata changes, add the broadcastSystemMetadataChange() method that finds replica MNs in the node list and calls systemMetadataChanged(). Modify setReplicationStatus() and updateReplicationMetadata() to fire this off when a replica status changes to completed. We may decide to inform MNs at other times too, but this is a conservative amount of calls going to the MNs for now.