Project

General

Profile

« Previous | Next » 

Revision 7600

Added by Chris Jones over 11 years ago

Merging the METACAT_2_0_6_BRANCH changes for [M|C]NodeService into the trunk.

View differences:

src/edu/ucsb/nceas/metacat/dataone/MNodeService.java
1117 1117
        throws NotImplemented, ServiceFailure, NotAuthorized, InvalidRequest,
1118 1118
        InvalidToken {
1119 1119
        
1120
        // cannot be called by public
1121
        if (session == null) {
1122
        	throw new InvalidToken("2183", "No session was provided.");
1123
        }
1124

  
1120 1125
        SystemMetadata currentLocalSysMeta = null;
1121 1126
        SystemMetadata newSysMeta = null;
1122 1127
        CNode cn = D1Client.getCN();
src/edu/ucsb/nceas/metacat/dataone/CNodeService.java
576 576
              int count = 0;
577 577
              
578 578
              // was there a failure? log it
579
              if ( failure != null && status == ReplicationStatus.FAILED ) {
579
              if ( failure != null && status.equals(ReplicationStatus.FAILED) ) {
580 580
                 String msg = "The replication request of the object identified by " + 
581 581
                     pid.getValue() + " failed.  The error message was " +
582 582
                     failure.getMessage() + ".";
......
585 585
              if (replicas.size() > 0 && replicas != null) {
586 586
                  // find the target replica index in the replica list
587 587
                  for (Replica replica : replicas) {
588
                      String replicaNodeStr = replica.getReplicaMemberNode()
589
                              .getValue();
588
                      String replicaNodeStr = replica.getReplicaMemberNode().getValue();
590 589
                      String targetNodeStr = targetNode.getValue();
591
                      logMetacat.debug("Comparing " + replicaNodeStr + " to "
592
                              + targetNodeStr);
590
                      logMetacat.debug("Comparing " + replicaNodeStr + " to " + targetNodeStr);
593 591
                  
594 592
                      if (replicaNodeStr.equals(targetNodeStr)) {
595 593
                          replicaEntryIndex = count;
......
609 607
              for ( Node node : nodes ) {
610 608
                  
611 609
                  NodeReference nodeReference = node.getIdentifier();
612
                  logMetacat.debug("In setReplicationStatus(), Node reference is: " + nodeReference.getValue());
610
                  logMetacat.debug("In setReplicationStatus(), Node reference is: " + 
611
                      nodeReference.getValue());
613 612
                  
614 613
                  // allow target MN certs
615
                  if (targetNode.getValue().equals(nodeReference.getValue()) &&
616
                      node.getType() == NodeType.MN) {
614
                  if ( targetNode.getValue().equals(nodeReference.getValue() ) &&
615
                      node.getType().equals(NodeType.MN)) {
617 616
                      List<Subject> nodeSubjects = node.getSubjectList();
618 617
                      
619 618
                      // check if the session subject is in the node subject list
......
624 623
                              
625 624
                              // lastly limit to COMPLETED, INVALIDATED,
626 625
                              // and FAILED status updates from MNs only
627
                              if ( status == ReplicationStatus.COMPLETED ||
628
                                   status == ReplicationStatus.INVALIDATED ||
629
                                   status == ReplicationStatus.FAILED) {
626
                              if ( status.equals(ReplicationStatus.COMPLETED) ||
627
                                   status.equals(ReplicationStatus.INVALIDATED) ||
628
                                   status.equals(ReplicationStatus.FAILED)) {
630 629
                                  allowed = true;
631 630
                                  break;
632 631
                                  
......
666 665
              
667 666
              // don't allow status to change from COMPLETED to anything other
668 667
              // than INVALIDATED: prevents overwrites from race conditions
669
              if ( targetReplica.getReplicationStatus() == ReplicationStatus.COMPLETED &&
670
            	   status != ReplicationStatus.INVALIDATED) {
668
              if ( targetReplica.getReplicationStatus().equals(ReplicationStatus.COMPLETED) &&
669
            	   !status.equals(ReplicationStatus.INVALIDATED)) {
671 670
            	  throw new InvalidRequest("4730", "Status state change from " +
672 671
            			  targetReplica.getReplicationStatus() + " to " +
673 672
            			  status.toString() + "is prohibited for identifier " +
......
699 698
              systemMetadata.setDateSysMetadataModified(Calendar.getInstance().getTime());
700 699
              HazelcastService.getInstance().getSystemMetadataMap().put(systemMetadata.getIdentifier(), systemMetadata);
701 700

  
702
              if ( status != ReplicationStatus.QUEUED && status != ReplicationStatus.REQUESTED) {
701
              if ( !status.equals(ReplicationStatus.QUEUED) && 
702
            	   !status.equals(ReplicationStatus.REQUESTED)) {
703 703
                  
704 704
                logMetacat.trace("METRICS:\tREPLICATION:\tEND REQUEST:\tPID:\t" + pid.getValue() + 
705 705
                          "\tNODE:\t" + targetNode.getValue() + 
......
711 711
                          "\tSIZE:\t" + systemMetadata.getSize().intValue());
712 712
              }
713 713

  
714
              if ( status == ReplicationStatus.FAILED && failure != null ) {
714
              if ( status.equals(ReplicationStatus.FAILED) && failure != null ) {
715 715
                  logMetacat.warn("Replication failed for identifier " + pid.getValue() +
716 716
                      " on target node " + targetNode + ". The exception was: " +
717 717
                      failure.getMessage());
718 718
              }
719 719
              
720 720
			  // update the replica nodes about the completed replica when complete
721
              if (status == ReplicationStatus.COMPLETED) {
721
              if (status.equals(ReplicationStatus.COMPLETED)) {
722 722
				broadcastSystemMetadataChange(systemMetadata);
723 723
			}
724 724
          
......
765 765
		    NodeReference nodeId = replica.getReplicaMemberNode();
766 766
		    try {
767 767
		        for (Node node : nodes) {
768
		      	    if (node.getIdentifier() == nodeId) {
769
		      		    if ( node.getType() == NodeType.MN) {
768
		      	    if ( node.getIdentifier().equals(nodeId) ) {
769
		      		    if ( node.getType().equals(NodeType.MN) ) {
770 770
		      		        MNode replicaNode = D1Client.getMN(nodeId);
771 771
		      		        // call MN.systemMetadataChanged();
772 772
		      		        replicaNode.systemMetadataChanged(null, 
......
1565 1565
              if ( replicaNode.getValue().equals(listedReplica.getReplicaMemberNode().getValue())) {
1566 1566
                      // don't allow status to change from COMPLETED to anything other
1567 1567
                      // than INVALIDATED: prevents overwrites from race conditions
1568
                	  if ( listedReplica.getReplicationStatus() != replicaStatus && 
1569
                	       listedReplica.getReplicationStatus() == ReplicationStatus.COMPLETED &&
1570
            		       replicaStatus != ReplicationStatus.INVALIDATED ) {
1568
                	  if ( !listedReplica.getReplicationStatus().equals(replicaStatus) && 
1569
                	       listedReplica.getReplicationStatus().equals(ReplicationStatus.COMPLETED) &&
1570
            		       !replicaStatus.equals(ReplicationStatus.INVALIDATED) ) {
1571 1571
                	  throw new InvalidRequest("4853", "Status state change from " +
1572 1572
                			  listedReplica.getReplicationStatus() + " to " +
1573 1573
                			  replicaStatus.toString() + "is prohibited for identifier " +
......
1593 1593
              HazelcastService.getInstance().getSystemMetadataMap().put(systemMetadata.getIdentifier(), systemMetadata);
1594 1594
              
1595 1595
              // inform replica nodes of the change if the status is complete
1596
              if ( replicaStatus == ReplicationStatus.COMPLETED ) {
1596
              if ( replicaStatus.equals(ReplicationStatus.COMPLETED) ) {
1597 1597
            	  broadcastSystemMetadataChange(systemMetadata);
1598 1598
            	  
1599 1599
              }

Also available in: Unified diff