Subversion Repositories DevTools

Rev

Rev 7032 | Rev 7082 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7032 Rev 7033
Line 1... Line 1...
1
package com.erggroup.buildtool.ripple;
1
package com.erggroup.buildtool.ripple;
2
 
2
 
3
import org.apache.log4j.Logger;
3
import org.slf4j.Logger;
-
 
4
import org.slf4j.LoggerFactory;
4
 
5
 
5
import com.erggroup.buildtool.smtp.CreateUrls;
6
import com.erggroup.buildtool.smtp.CreateUrls;
6
import com.erggroup.buildtool.smtp.Smtpsend;
7
import com.erggroup.buildtool.smtp.Smtpsend;
7
 
8
 
8
import java.sql.SQLException;
9
import java.sql.SQLException;
Line 14... Line 15...
14
public class BuildExclusion
15
public class BuildExclusion
15
{
16
{
16
  /**Logger
17
  /**Logger
17
   * @attribute
18
   * @attribute
18
   */
19
   */
19
  private static final Logger mLogger = Logger.getLogger(BuildExclusion.class);
20
  private static final Logger mLogger = LoggerFactory.getLogger(BuildExclusion.class);
20
 
21
 
21
  /**The pvid of the package being excluded
22
  /**The pvid of the package being excluded
22
   * @attribute
23
   * @attribute
23
   */
24
   */
24
  private int mId;
25
  private int mId;
Line 69... Line 70...
69
 
70
 
70
  /**sets mProcessed true
71
  /**sets mProcessed true
71
   */
72
   */
72
  void setProcessed()
73
  void setProcessed()
73
  {
74
  {
74
    mLogger.debug("process " + mId);
75
    mLogger.debug("process {}", mId);
75
    mProcessed = true;
76
    mProcessed = true;
76
  }
77
  }
77
 
78
 
78
  /** @returns true if the item has been marked as processed. 
79
  /** @returns true if the item has been marked as processed. 
79
   * Appears to be an indication that the entry has been superseded.
80
   * Appears to be an indication that the entry has been superseded.
80
   */
81
   */
81
  boolean isProcessed()
82
  boolean isProcessed()
82
  {
83
  {
83
    mLogger.debug("isProcessed " + mId);
84
    mLogger.debug("isProcessed {}", mId);
84
    mLogger.info("isProcessed returned " + mProcessed);
85
    mLogger.info("isProcessed returned {}", mProcessed);
85
    return mProcessed;
86
    return mProcessed;
86
  }
87
  }
87
  
88
  
88
  /** Flag as an imported entry
89
  /** Flag as an imported entry
89
   *  Used to detect indirect exclusions that are no longer valid
90
   *  Used to detect indirect exclusions that are no longer valid
Line 108... Line 109...
108
   * @param  rootCause          - Root cause string. May be null
109
   * @param  rootCause          - Root cause string. May be null
109
   * @return true if all attributes match
110
   * @return true if all attributes match
110
   */
111
   */
111
  boolean compare( int identifier, int rootIdentifier, String rootCause)
112
  boolean compare( int identifier, int rootIdentifier, String rootCause)
112
  {
113
  {
113
    mLogger.debug("compare " + mId + ", " + identifier + ", " + rootIdentifier + ", " + rootCause);
114
    mLogger.debug("compare {}, {}, {}, {}", mId, identifier, rootIdentifier,  rootCause);
114
    boolean retVal = false;
115
    boolean retVal = false;
115
    rootIdentifier = dealWithNullRootPvId(identifier, rootIdentifier);
116
    rootIdentifier = dealWithNullRootPvId(identifier, rootIdentifier);
116
    
117
    
117
    if ( mRootCause == null )
118
    if ( mRootCause == null )
118
    {
119
    {
Line 127... Line 128...
127
      {
128
      {
128
        retVal = true;
129
        retVal = true;
129
      }
130
      }
130
    }
131
    }
131
    
132
    
132
    mLogger.info("compare returned " + retVal);
133
    mLogger.info("compare returned {}", retVal);
133
    return retVal;
134
    return retVal;
134
  }
135
  }
135
  
136
  
136
  /**
137
  /**
137
   * @param identifier  - identifier to match
138
   * @param identifier  - identifier to match
138
   * @return true if mId attribute matches
139
   * @return true if mId attribute matches
139
   */
140
   */
140
  boolean compare( int identifier )
141
  boolean compare( int identifier )
141
  {
142
  {
142
    mLogger.debug("compare " + mId + ", " + identifier);
143
    mLogger.debug("compare {},{}", mId,  identifier);
143
    boolean retVal = false;
144
    boolean retVal = false;
144
    
145
    
145
    if ( mId == identifier )
146
    if ( mId == identifier )
146
    {
147
    {
147
      retVal = true;
148
      retVal = true;
148
    }
149
    }
149
    
150
    
150
    mLogger.info("compare returned " + retVal);
151
    mLogger.info("compare returned {}", retVal);
151
    return retVal;
152
    return retVal;
152
  }
153
  }
153
  
154
  
154
  /**runs exclude from build
155
  /**runs exclude from build
155
   * Assumes that a connection to RM has been established
156
   * Assumes that a connection to RM has been established
156
   * 
157
   * 
157
   * @param rm          Release Manager instance
158
   * @param rm          Release Manager instance
158
   * @param rtag_id     Rtag Id we are working against
159
   * @param rtagId      Rtag Id we are working against
159
   */
160
   */
160
  void excludeFromBuild( ReleaseManager rm, int rtag_id ) throws SQLException, Exception
161
  void excludeFromBuild( ReleaseManager rm, int rtagId ) throws SQLException, Exception
161
  {
162
  {
162
    mLogger.debug("excludeFromBuild " + mId);
163
    mLogger.debug("excludeFromBuild {}", mId);
163
    
164
    
164
    // a null version and log file is passed to oracle
165
    // a null version and log file is passed to oracle
165
    // the planned version is only needed to remove a planned version from the planned version table
166
    // the planned version is only needed to remove a planned version from the planned version table
166
    // the ripple engine does not get this far ie it excludes pvs before claiming a version
167
    // the ripple engine does not get this far ie it excludes pvs before claiming a version
167
    // this is the one instance where an existing build failure must be superseded in the database
168
    // this is the one instance where an existing build failure must be superseded in the database
168
    rm.excludeFromBuild(true, 
169
    rm.excludeFromBuild(true, 
169
                        mId, 
170
                        mId, 
170
                        null, 
171
                        null, 
171
                        rtag_id, 
172
                        rtagId, 
172
    		            mRootId == -1 ? null : String.valueOf(mRootId), 
173
    		            mRootId == -1 ? null : String.valueOf(mRootId), 
173
    		            mRootCause, 
174
    		            mRootCause, 
174
    		            null, 
175
    		            null, 
175
    		            true, (mTestBuildInstruction > 0) );
176
    		            true, (mTestBuildInstruction > 0) );
176
  }
177
  }
177
  
178
  
178
  /**runs include to build
179
  /**runs include to build
179
   * Include a previously excluded package-version back into the build set
180
   * Include a previously excluded package-version back into the build set
180
   * 
181
   * 
181
   * @param rm          Release Manager instance
182
   * @param rm          Release Manager instance
182
   * @param rtag_id     Rtag Id we are working against
183
   * @param rtagId      Rtag Id we are working against
183
   */
184
   */
184
  void includeToBuild( ReleaseManager rm, int rtag_id ) throws SQLException, Exception
185
  void includeToBuild( ReleaseManager rm, int rtagId ) throws SQLException, Exception
185
  {
186
  {
186
    mLogger.debug("includeToBuild " + mId);
187
    mLogger.debug("includeToBuild {}", mId);
187
    rm.includeToBuild(mId, rtag_id);
188
    rm.includeToBuild(mId, rtagId);
188
  }
189
  }
189
  
190
  
190
  /**
191
  /**
191
   * Match this items id against that provided
192
   * Match this items id against that provided
192
   * @param id  - Id to match
193
   * @param id  - Id to match
193
   * @return true if id matches mId
194
   * @return true if id matches mId
194
   */
195
   */
195
    private boolean isRelevant(int id)
196
    private boolean isRelevant(int id)
196
    {
197
    {
197
      mLogger.debug("isRelevant " + mId + ", " + id);
198
      mLogger.debug("isRelevant {},{}", mId, id);
198
      boolean retVal = false;
199
      boolean retVal = false;
199
      
200
      
200
      if ( mId == id )
201
      if ( mId == id )
201
      {
202
      {
202
        retVal = true;
203
        retVal = true;
203
      }
204
      }
204
 
205
 
205
      mLogger.info("isRelevant " + mId +  ", " + id + " returned " + retVal);
206
      mLogger.info("isRelevant {},{}, returned {}",  mId,  id, retVal);
206
      return retVal;
207
      return retVal;
207
    }
208
    }
208
    
209
    
209
  /**
210
  /**
210
   * Match this items mRootId against the id's provided in a collection
211
   * Match this items mRootId against the id's provided in a collection
Line 215... Line 216...
215
   * @param buildExclusionCollection - Collection to be processed
216
   * @param buildExclusionCollection - Collection to be processed
216
   * @return false: Indirectly excluded package whose root cause no longer exists
217
   * @return false: Indirectly excluded package whose root cause no longer exists
217
   */
218
   */
218
  boolean isRelevant(ArrayList<BuildExclusion> buildExclusionCollection)
219
  boolean isRelevant(ArrayList<BuildExclusion> buildExclusionCollection)
219
  {
220
  {
220
    mLogger.debug("isRelevant " + mId);
221
    mLogger.debug("isRelevant {}", mId);
221
    boolean retVal = false;
222
    boolean retVal = false;
222
    
223
    
223
    if ( mRootId == -1 )     {
224
    if ( mRootId == -1 )     {
224
      retVal = true;
225
      retVal = true;
225
      
226
      
Line 241... Line 242...
241
          break;
242
          break;
242
        }
243
        }
243
      }
244
      }
244
    }
245
    }
245
 
246
 
246
    mLogger.info("isRelevant " + mId + " returned " + retVal);
247
    mLogger.info("isRelevant {} returned {}", mId, retVal);
247
    return retVal;
248
    return retVal;
248
  }
249
  }
249
 
250
 
250
  /**
251
  /**
251
   * @return true if the root_pv_id is null (-1). This indicates that the item is the root case, and is not simply
252
   * @return true if the root_pv_id is null (-1). This indicates that the item is the root case, and is not simply
252
   *         a by product of some other cause.
253
   *         a by product of some other cause.
253
   */
254
   */
254
  boolean isARootCause()
255
  boolean isARootCause()
255
  {
256
  {
256
    mLogger.debug("isARootCause " + mId);
257
    mLogger.debug("isARootCause {}", mId);
257
    boolean retVal = false;
258
    boolean retVal = false;
258
    
259
    
259
    if ( mRootId == -1 )
260
    if ( mRootId == -1 )
260
    {
261
    {
261
      retVal = true;
262
      retVal = true;
262
    }
263
    }
263
 
264
 
264
    mLogger.info("isARootCause " + mId + " returned " + retVal);
265
    mLogger.info("isARootCause {} returned {}",mId, retVal);
265
    return retVal;
266
    return retVal;
266
  }
267
  }
267
 
268
 
268
  /**
269
  /**
269
   * Send an email notifying users about a build excluded package
270
   * Send an email notifying users about a build excluded package
Line 276... Line 277...
276
   * @param    rippleEngine        - Ripple Engine Instance
277
   * @param    rippleEngine        - Ripple Engine Instance
277
   * @param    packageCollection   - Collection to process
278
   * @param    packageCollection   - Collection to process
278
   */
279
   */
279
    public void email(RippleEngine rippleEngine, ArrayList<Package> packageCollection) throws SQLException, Exception
280
    public void email(RippleEngine rippleEngine, ArrayList<Package> packageCollection) throws SQLException, Exception
280
    {
281
    {
281
      mLogger.debug("email " + mId);
282
      mLogger.debug("email {}", mId);
282
      
283
      
283
      //
284
      //
284
      //    Only process entries that are direct failures of ripple engine detected failure
285
      //    Only process entries that are direct failures of ripple engine detected failure
285
      //    Do not process entries that are indirectly excluded as this will cause an email storm
286
      //    Do not process entries that are indirectly excluded as this will cause an email storm
286
      //    Direct build failure: 
287
      //    Direct build failure: 
Line 319... Line 320...
319
              null                                      // attachment
320
              null                                      // attachment
320
              );
321
              );
321
            }
322
            }
322
            catch( Exception e )
323
            catch( Exception e )
323
            {
324
            {
-
 
325
                mLogger.info("email send exception. {}", e);
324
            }
326
            }
325
          }
327
          }
326
          
328
          
327
          // Having sent the build failure email, complete a test build if applicable.
329
          // Having sent the build failure email, complete a test build if applicable.
328
          // This ensures the test build instruction is not processed indefinitely
330
          // This ensures the test build instruction is not processed indefinitely