Project

General

Profile

« Previous | Next » 

Revision 7073

Add a notifyReplicaNodes() method that calls MNStorage.systemMetadataChanged() on MN replica nodes for a given object identifier. This will be called when there are changes to AccessPolicy and rights holder since these are critical access metadata for an MN, but they can only be changed on the CN.

View differences:

src/edu/ucsb/nceas/metacat/dataone/CNodeService.java
36 36
import org.apache.log4j.Logger;
37 37
import org.dataone.client.CNode;
38 38
import org.dataone.client.D1Client;
39
import org.dataone.client.MNode;
39 40
import org.dataone.service.cn.v1.CNAuthorization;
40 41
import org.dataone.service.cn.v1.CNCore;
41 42
import org.dataone.service.cn.v1.CNRead;
......
1500 1501
		return cal;
1501 1502
		
1502 1503
	}
1503
    
1504

  
1505
  /**
1506
   * Notify replica Member Nodes of system metadata changes for a given pid
1507
   * 
1508
   * @param currentSystemMetadata - the up to date system metadata
1509
   */
1510
  public void notifyReplicaNodes(SystemMetadata currentSystemMetadata) {
1511
      
1512
      Session session = null;
1513
      List<Replica> replicaList = currentSystemMetadata.getReplicaList();
1514
      MNode mn = null;
1515
      NodeReference replicaNodeRef = null;
1516
      CNode cn = null;
1517
      NodeType nodeType = null;
1518
      List<Node> nodeList = null;
1519
      
1520
      try {
1521
          cn = D1Client.getCN();
1522
          nodeList = cn.listNodes().getNodeList();
1523
          
1524
      } catch (Exception e) { // handle BaseException and other I/O issues
1525
          
1526
          // swallow errors since the call is not critical
1527
          logMetacat.error("Can't inform MNs of system metadata changes due " +
1528
              "to communication issues with the CN: " + e.getMessage());
1529
          
1530
      }
1531
      
1532
      if ( replicaList != null ) {
1533
          
1534
          // iterate through the replicas and inform  MN replica nodes
1535
          for (Replica replica : replicaList) {
1536
              
1537
              replicaNodeRef = replica.getReplicaMemberNode();
1538
              try {
1539
                  if (nodeList != null) {
1540
                      // find the node type
1541
                      for (Node node : nodeList) {
1542
                          if (node.getIdentifier().getValue() == 
1543
                              replicaNodeRef.getValue()) {
1544
                              nodeType = node.getType();
1545
                              break;
1546
              
1547
                          }
1548
                      }
1549
                  }
1550
              
1551
                  // notify only MNs
1552
                  if (nodeType != null && nodeType == NodeType.MN) {
1553
                      mn = D1Client.getMN(replicaNodeRef);
1554
                      mn.systemMetadataChanged(session, 
1555
                          currentSystemMetadata.getIdentifier(), 
1556
                          currentSystemMetadata.getSerialVersion().longValue(),
1557
                          currentSystemMetadata.getDateSysMetadataModified());
1558
                  }
1559
              
1560
              } catch (Exception e) { // handle BaseException and other I/O issues
1561
              
1562
                  // swallow errors since the call is not critical
1563
                  logMetacat.error("Can't inform "
1564
                          + replicaNodeRef.getValue()
1565
                          + " of system metadata changes due "
1566
                          + "to communication issues with the CN: "
1567
                          + e.getMessage());
1568
              
1569
              }
1570
          }
1571
      }
1572
  }
1504 1573
}

Also available in: Unified diff