Project

General

Profile

« Previous | Next » 

Revision 9295

Added by Jing Tao over 9 years ago

Use the D1NodeVersionChecker to determine the mn's version rather than using ping.

View differences:

src/edu/ucsb/nceas/metacat/dataone/MNodeService.java
193 193
    private Logger logMetacat = null;
194 194
    
195 195
    /* A reference to a remote Memeber Node */
196
    private MNode mn;
196
    //private MNode mn;
197 197
    
198 198
    /* A reference to a Coordinating Node */
199 199
    private CNode cn;
......
644 644

  
645 645
        // get from the membernode
646 646
        // TODO: switch credentials for the server retrieval?
647
        this.mn = D1Client.getMN(sourceNode);
648 647
        this.cn = D1Client.getCN();
649 648
        InputStream object = null;
650 649
        Session thisNodeSession = null;
......
712 711
            
713 712
            // no local replica, get a replica
714 713
            if ( object == null ) {
715
                boolean success = true;
714
                /*boolean success = true;
716 715
                try {
717 716
                    //use the v2 ping api to connect the source node
718 717
                    mn.ping();
719 718
                } catch (Exception e) {
720 719
                    success = false;
721
                }
722
                
723
                if(!success) {
724
                    //The failure maybe is caused by that the source node is not a v2 node. We try to use the v1 replication.
725
                    //If the failure is not caused by the version issue (e.g., it is a network connection issue), the following 
726
                    //command will fail as well.
720
                }*/
721
                D1NodeVersionChecker checker = new D1NodeVersionChecker(sourceNode);
722
                String nodeVersion = checker.getVersion("MNRead");
723
                if(nodeVersion != null && nodeVersion.equals(D1NodeVersionChecker.V1)) {
724
                    //The source node is a v1 node, we use the v1 api
727 725
                    org.dataone.client.v1.MNode mNodeV1 =  org.dataone.client.v1.itk.D1Client.getMN(sourceNode);
728
                    object = mNodeV1.get(thisNodeSession, pid);
729
                } else {
726
                    object = mNodeV1.getReplica(thisNodeSession, pid);
727
                } else if (nodeVersion != null && nodeVersion.equals(D1NodeVersionChecker.V2)){
730 728
                 // session should be null to use the default certificate
731 729
                    // location set in the Certificate manager
730
                    MNode mn = D1Client.getMN(sourceNode);
732 731
                    object = mn.getReplica(thisNodeSession, pid);
732
                } else {
733
                    throw new ServiceFailure("2151", "The version of MNRead service is "+nodeVersion+" in the source node "+sourceNode.getValue()+" and it is supported. Please check the information in the cn");
733 734
                }
734 735
                
735 736
                logMetacat.info("MNodeService.getReplica() called for identifier "

Also available in: Unified diff