Project

General

Profile

« Previous | Next » 

Revision 9176

Added by Jing Tao over 9 years ago

Add the code to check if the current node is the authoritative node for the the given pid.

View differences:

src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java
50 50
import org.dataone.client.v2.CNode;
51 51
import org.dataone.client.v2.itk.D1Client;
52 52
import org.dataone.client.v2.formats.ObjectFormatCache;
53
import org.dataone.configuration.Settings;
53 54
import org.dataone.service.exceptions.BaseException;
54 55
import org.dataone.service.exceptions.IdentifierNotUnique;
55 56
import org.dataone.service.exceptions.InsufficientResources;
......
1596 1597
      } catch (SQLException e) {
1597 1598
          logMetacat.warn("Could not log 'updateSystemMetadata' event because the localId couldn't be identified for the pid: " + pid.getValue());
1598 1599
      }
1599
      
1600
      boolean ifAuthoritativeNode = isAuthoritativeNode(pid);
1600 1601
      return true;
1601 1602
	}
1602 1603
	
1604
	private boolean isAuthoritativeNode(Identifier pid) {
1605
	    boolean isAuthoritativeNode = false;
1606
	    if(pid != null && pid.getValue() != null) {
1607
	        SystemMetadata sys = HazelcastService.getInstance().getSystemMetadataMap().get(pid);
1608
	        if(sys != null) {
1609
	            NodeReference node = sys.getAuthoritativeMemberNode();
1610
	            if(node != null) {
1611
	                String nodeValue = node.getValue();
1612
	                logMetacat.debug("The authoritative node for id "+pid.getValue()+" is "+nodeValue);
1613
	                //System.out.println("The authoritative node for id "+pid.getValue()+" is "+nodeValue);
1614
	                String currentNodeId = Settings.getConfiguration().getString("dataone.nodeId");
1615
	                logMetacat.debug("The node id in metacat.properties is "+currentNodeId);
1616
	                //System.out.println("The node id in metacat.properties is "+currentNodeId);
1617
	                if(currentNodeId != null && !currentNodeId.trim().equals("") && currentNodeId.equals(nodeValue)) {
1618
	                    logMetacat.debug("They are matching");
1619
	                    //System.out.println("They are matching");
1620
	                    isAuthoritativeNode = true;
1621
	                }
1622
	            }
1623
	        }
1624
	    }
1625
	    return isAuthoritativeNode;
1626
	}
1627
	
1603 1628
	/*
1604 1629
	 * Check if the newMeta modifies an immutable field. 
1605 1630
	 */

Also available in: Unified diff