Project

General

Profile

« Previous | Next » 

Revision 9253

Added by Jing Tao over 9 years ago

Handle multiple versions (v1 and v2) of a service in getCapacity method.

View differences:

src/edu/ucsb/nceas/metacat/dataone/MNodeService.java
963 963
        String nodeDesc = null;
964 964
        String nodeTypeString = null;
965 965
        NodeType nodeType = null;
966
        String mnCoreServiceVersion = null;
967
        String mnReadServiceVersion = null;
968
        String mnAuthorizationServiceVersion = null;
969
        String mnStorageServiceVersion = null;
970
        String mnReplicationServiceVersion = null;
966
        List<String> mnCoreServiceVersions = null;
967
        List<String> mnReadServiceVersions = null;
968
        List<String> mnAuthorizationServiceVersions = null;
969
        List<String> mnStorageServiceVersions = null;
970
        List<String> mnReplicationServiceVersions = null;
971 971

  
972 972
        boolean nodeSynchronize = false;
973 973
        boolean nodeReplicate = false;
974
        boolean mnCoreServiceAvailable = false;
975
        boolean mnReadServiceAvailable = false;
976
        boolean mnAuthorizationServiceAvailable = false;
977
        boolean mnStorageServiceAvailable = false;
978
        boolean mnReplicationServiceAvailable = false;
974
        List<String> mnCoreServiceAvailables = null;
975
        List<String> mnReadServiceAvailables = null;
976
        List<String> mnAuthorizationServiceAvailables = null;
977
        List<String> mnStorageServiceAvailables = null;
978
        List<String> mnReplicationServiceAvailables = null;
979 979

  
980 980
        try {
981 981
            // get the properties of the node based on configuration information
982
            nodeName = PropertyService.getProperty("dataone.nodeName");
983
            nodeId = PropertyService.getProperty("dataone.nodeId");
984
            subject = PropertyService.getProperty("dataone.subject");
985
            contactSubject = PropertyService.getProperty("dataone.contactSubject");
986
            nodeDesc = PropertyService.getProperty("dataone.nodeDescription");
987
            nodeTypeString = PropertyService.getProperty("dataone.nodeType");
982
            nodeName = Settings.getConfiguration().getString("dataone.nodeName");
983
            nodeId = Settings.getConfiguration().getString("dataone.nodeId");
984
            subject = Settings.getConfiguration().getString("dataone.subject");
985
            contactSubject = Settings.getConfiguration().getString("dataone.contactSubject");
986
            nodeDesc = Settings.getConfiguration().getString("dataone.nodeDescription");
987
            nodeTypeString = Settings.getConfiguration().getString("dataone.nodeType");
988 988
            nodeType = NodeType.convert(nodeTypeString);
989
            nodeSynchronize = new Boolean(PropertyService.getProperty("dataone.nodeSynchronize")).booleanValue();
990
            nodeReplicate = new Boolean(PropertyService.getProperty("dataone.nodeReplicate")).booleanValue();
989
            nodeSynchronize = new Boolean(Settings.getConfiguration().getString("dataone.nodeSynchronize")).booleanValue();
990
            nodeReplicate = new Boolean(Settings.getConfiguration().getString("dataone.nodeReplicate")).booleanValue();
991 991

  
992
            mnCoreServiceVersion = PropertyService.getProperty("dataone.mnCore.serviceVersion");
993
            mnReadServiceVersion = PropertyService.getProperty("dataone.mnRead.serviceVersion");
994
            mnAuthorizationServiceVersion = PropertyService.getProperty("dataone.mnAuthorization.serviceVersion");
995
            mnStorageServiceVersion = PropertyService.getProperty("dataone.mnStorage.serviceVersion");
996
            mnReplicationServiceVersion = PropertyService.getProperty("dataone.mnReplication.serviceVersion");
997

  
998
            mnCoreServiceAvailable = new Boolean(PropertyService.getProperty("dataone.mnCore.serviceAvailable")).booleanValue();
999
            mnReadServiceAvailable = new Boolean(PropertyService.getProperty("dataone.mnRead.serviceAvailable")).booleanValue();
1000
            mnAuthorizationServiceAvailable = new Boolean(PropertyService.getProperty("dataone.mnAuthorization.serviceAvailable")).booleanValue();
1001
            mnStorageServiceAvailable = new Boolean(PropertyService.getProperty("dataone.mnStorage.serviceAvailable")).booleanValue();
1002
            mnReplicationServiceAvailable = new Boolean(PropertyService.getProperty("dataone.mnReplication.serviceAvailable")).booleanValue();
1003

  
1004 992
            // Set the properties of the node based on configuration information and
1005 993
            // calls to current status methods
1006 994
            String serviceName = SystemUtil.getSecureContextURL() + "/" + PropertyService.getProperty("dataone.serviceName");
......
1040 1028
            // services: MNAuthorization, MNCore, MNRead, MNReplication, MNStorage
1041 1029
            Services services = new Services();
1042 1030

  
1043
            Service sMNCore = new Service();
1044
            sMNCore.setName("MNCore");
1045
            sMNCore.setVersion(mnCoreServiceVersion);
1046
            sMNCore.setAvailable(mnCoreServiceAvailable);
1047

  
1048
            Service sMNRead = new Service();
1049
            sMNRead.setName("MNRead");
1050
            sMNRead.setVersion(mnReadServiceVersion);
1051
            sMNRead.setAvailable(mnReadServiceAvailable);
1052

  
1053
            Service sMNAuthorization = new Service();
1054
            sMNAuthorization.setName("MNAuthorization");
1055
            sMNAuthorization.setVersion(mnAuthorizationServiceVersion);
1056
            sMNAuthorization.setAvailable(mnAuthorizationServiceAvailable);
1057

  
1058
            Service sMNStorage = new Service();
1059
            sMNStorage.setName("MNStorage");
1060
            sMNStorage.setVersion(mnStorageServiceVersion);
1061
            sMNStorage.setAvailable(mnStorageServiceAvailable);
1062

  
1063
            Service sMNReplication = new Service();
1064
            sMNReplication.setName("MNReplication");
1065
            sMNReplication.setVersion(mnReplicationServiceVersion);
1066
            sMNReplication.setAvailable(mnReplicationServiceAvailable);
1067

  
1068
            services.addService(sMNRead);
1069
            services.addService(sMNCore);
1070
            services.addService(sMNAuthorization);
1071
            services.addService(sMNStorage);
1072
            services.addService(sMNReplication);
1031
            mnCoreServiceVersions = Settings.getConfiguration().getList("dataone.mnCore.serviceVersion");
1032
            mnCoreServiceAvailables = Settings.getConfiguration().getList("dataone.mnCore.serviceAvailable");
1033
            if(mnCoreServiceVersions != null && mnCoreServiceAvailables != null && mnCoreServiceVersions.size() == mnCoreServiceAvailables.size()) {
1034
                for(int i=0; i<mnCoreServiceVersions.size(); i++) {
1035
                    String version = mnCoreServiceVersions.get(i);
1036
                    boolean available = new Boolean(mnCoreServiceAvailables.get(i)).booleanValue();
1037
                    Service sMNCore = new Service();
1038
                    sMNCore.setName("MNCore");
1039
                    sMNCore.setVersion(version);
1040
                    sMNCore.setAvailable(available);
1041
                    services.addService(sMNCore);
1042
                }
1043
            }
1044
            
1045
            mnReadServiceVersions = Settings.getConfiguration().getList("dataone.mnRead.serviceVersion");
1046
            mnReadServiceAvailables = Settings.getConfiguration().getList("dataone.mnRead.serviceAvailable");
1047
            if(mnReadServiceVersions != null && mnReadServiceAvailables != null && mnReadServiceVersions.size()==mnReadServiceAvailables.size()) {
1048
                for(int i=0; i<mnReadServiceVersions.size(); i++) {
1049
                    String version = mnReadServiceVersions.get(i);
1050
                    boolean available = new Boolean(mnReadServiceAvailables.get(i)).booleanValue();
1051
                    Service sMNRead = new Service();
1052
                    sMNRead.setName("MNRead");
1053
                    sMNRead.setVersion(version);
1054
                    sMNRead.setAvailable(available);
1055
                    services.addService(sMNRead);
1056
                }
1057
            }
1058
           
1059
            mnAuthorizationServiceVersions = Settings.getConfiguration().getList("dataone.mnAuthorization.serviceVersion");
1060
            mnAuthorizationServiceAvailables = Settings.getConfiguration().getList("dataone.mnAuthorization.serviceAvailable");
1061
            if(mnAuthorizationServiceVersions != null && mnAuthorizationServiceAvailables != null && mnAuthorizationServiceVersions.size()==mnAuthorizationServiceAvailables.size()) {
1062
                for(int i=0; i<mnAuthorizationServiceVersions.size(); i++) {
1063
                    String version = mnAuthorizationServiceVersions.get(i);
1064
                    boolean available = new Boolean(mnAuthorizationServiceAvailables.get(i)).booleanValue();
1065
                    Service sMNAuthorization = new Service();
1066
                    sMNAuthorization.setName("MNAuthorization");
1067
                    sMNAuthorization.setVersion(version);
1068
                    sMNAuthorization.setAvailable(available);
1069
                    services.addService(sMNAuthorization);
1070
                }
1071
            }
1072
           
1073
            mnStorageServiceVersions = Settings.getConfiguration().getList("dataone.mnStorage.serviceVersion");
1074
            mnStorageServiceAvailables = Settings.getConfiguration().getList("dataone.mnStorage.serviceAvailable");
1075
            if(mnStorageServiceVersions != null && mnStorageServiceAvailables != null && mnStorageServiceVersions.size() == mnStorageServiceAvailables.size()) {
1076
                for(int i=0; i<mnStorageServiceVersions.size(); i++) {
1077
                    String version = mnStorageServiceVersions.get(i);
1078
                    boolean available = new Boolean(mnStorageServiceAvailables.get(i)).booleanValue();
1079
                    Service sMNStorage = new Service();
1080
                    sMNStorage.setName("MNStorage");
1081
                    sMNStorage.setVersion(version);
1082
                    sMNStorage.setAvailable(available);
1083
                    services.addService(sMNStorage);
1084
                }
1085
            }
1086
            
1087
            mnReplicationServiceVersions = Settings.getConfiguration().getList("dataone.mnReplication.serviceVersion");
1088
            mnReplicationServiceAvailables = Settings.getConfiguration().getList("dataone.mnReplication.serviceAvailable");
1089
            if(mnReplicationServiceVersions != null && mnReplicationServiceAvailables != null && mnReplicationServiceVersions.size() == mnReplicationServiceAvailables.size()) {
1090
                for (int i=0; i<mnReplicationServiceVersions.size(); i++) {
1091
                    String version = mnReplicationServiceVersions.get(i);
1092
                    boolean available = new Boolean(mnReplicationServiceAvailables.get(i)).booleanValue();
1093
                    Service sMNReplication = new Service();
1094
                    sMNReplication.setName("MNReplication");
1095
                    sMNReplication.setVersion(version);
1096
                    sMNReplication.setAvailable(available);
1097
                    services.addService(sMNReplication);
1098
                }
1099
            }
1100
            
1073 1101
            node.setServices(services);
1074 1102

  
1075 1103
            // Set the schedule for synchronization

Also available in: Unified diff