Project

General

Profile

« Previous | Next » 

Revision 9634

Added by Jing Tao about 8 years ago

Use sql command to get some information rather than hazelcast.

View differences:

IdentifierManager.java
991 991
            DBConnection dbConn = null;
992 992
            int serialNumber = -1;
993 993
            PreparedStatement stmt = null;
994
            PreparedStatement stmt2 = null;
995
            ResultSet rs = null;
996
            ResultSet result = null;
994 997
            int endsCount = 0;
995 998
            boolean hasError = false;
996 999
            HashMap<String, String> obsoletesIdGuidMap = new HashMap<String, String>();//the key is an obsoletes id, the value is an guid
......
1001 1004
                // Execute the insert statement
1002 1005
                stmt = dbConn.prepareStatement(sql);
1003 1006
                stmt.setString(1, sid.getValue());
1004
                ResultSet rs = stmt.executeQuery();
1007
                rs = stmt.executeQuery();
1005 1008
                boolean hasNext = rs.next();
1006 1009
                boolean first = true;
1007 1010
                Identifier firstOne = new Identifier();//since the sql using the desc order, the first one has the latest upload date.
......
1036 1039
                            //Identifier obsoletedBy = sysmeta.getObsoletedBy();
1037 1040
                            Identifier obsoletedBy = new Identifier();
1038 1041
                            obsoletedBy.setValue(obsoletedByStr);
1039
                            SystemMetadata obsoletedBySysmeta = HazelcastService.getInstance().getSystemMetadataMap().get(obsoletedBy);
1040
                            if(obsoletedBySysmeta != null) {
1041
                                Identifier sidInObsoletedBy = obsoletedBySysmeta.getSeriesId();
1042
                                if(sidInObsoletedBy == null|| !sidInObsoletedBy.equals(sid)) {
1042
                            //SystemMetadata obsoletedBySysmeta = HazelcastService.getInstance().getSystemMetadataMap().get(obsoletedBy);
1043
                            String sql2 = "select series_id, guid from systemMetadata where guid = ? ";
1044
                            stmt2 = dbConn.prepareStatement(sql2);
1045
                            stmt2.setString(1, obsoletedByStr);
1046
                            result = stmt2.executeQuery();
1047
                            boolean next = result.next();
1048
                            //if(obsoletedBySysmeta != null) {
1049
                            if(next) {
1050
                                logMetacat.debug("The object "+obsoletedBy+" which obsoletes "+guidStr+" does have a system metadata on the table.");
1051
                                //Identifier sidInObsoletedBy = obsoletedBySysmeta.getSeriesId();
1052
                                String sidInObsoletedBy = result.getString(1);
1053
                                if(sidInObsoletedBy == null|| !sidInObsoletedBy.equals(sid.getValue())) {
1043 1054
                                    // type 2 end
1044
                                    logMetacat.debug(""+guidStr+" is a type 2 end for sid "+sid.getValue());
1055
                                    logMetacat.debug(""+guidStr+" is a type 2 end for sid "+sid.getValue()+ "since it is obsoleted by the object "+sidInObsoletedBy+
1056
                                            " which has a different sid or no sids");
1045 1057
                                    pid = guid;
1046 1058
                                    endsCount++;
1047 1059
                                }
1048 1060
                            } else {
1049
                                logMetacat.debug("The object "+obsoletedBy+" which obsoletes "+guidStr+" is missing.");
1061
                                logMetacat.debug("The object "+obsoletedBy+" which obsoletes "+guidStr+" is missing on the host.");
1050 1062
                                //obsoletedBySysmeta doesn't exist; it means the object is missing
1051 1063
                                //generally, we consider it we generally consider it a type 2 end except:
1052 1064
                                 //there is another object in the chain (has the same series id) that obsoletes the missing object. 
......
1104 1116
                    //it is not a sid or at least we don't have anything to match it.
1105 1117
                    //do nothing, so null will be returned
1106 1118
                }
1107
                if(rs != null) {
1108
                    rs.close();
1109
                }
1110 1119
                
1120
                
1111 1121
            } catch (SQLException e) {
1112 1122
                logMetacat.error("Error while get the head pid for the sid "+sid.getValue()+" : " 
1113 1123
                        + e.getMessage());
1114 1124
                throw e;
1115 1125
            } finally {
1116 1126
                try {
1127
                    if(rs != null) {
1128
                        rs.close();
1129
                    }
1130
                    if(result != null) {
1131
                        result.close();
1132
                    }
1117 1133
                    if(stmt != null) {
1118 1134
                        stmt.close();
1119 1135
                    }
1136
                    if(stmt2 != null) {
1137
                        stmt2.close();
1138
                    }
1120 1139
                } catch (Exception e) {
1121 1140
                    logMetacat.warn("Couldn't close the prepared statement since "+e.getMessage());
1122 1141
                } finally {

Also available in: Unified diff