Subversion Repositories DevTools

Rev

Rev 898 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 898 Rev 900
Line 19... Line 19...
19
import java.util.Iterator;
19
import java.util.Iterator;
20
import java.util.ListIterator;
20
import java.util.ListIterator;
21
import java.util.Vector;
21
import java.util.Vector;
22
import java.util.concurrent.locks.ReentrantLock;
22
import java.util.concurrent.locks.ReentrantLock;
23
 
23
 
24
import oracle.jdbc.OracleDriver;
-
 
25
 
-
 
26
import org.apache.log4j.Logger;
24
import org.apache.log4j.Logger;
27
 
25
 
28
/**Release Manager schema abstraction
26
/**Release Manager schema abstraction
29
 */
27
 */
30
public class ReleaseManager
28
public class ReleaseManager
Line 3665... Line 3663...
3665
        disconnect();
3663
        disconnect();
3666
      }
3664
      }
3667
    }
3665
    }
3668
  }
3666
  }
3669
 
3667
 
-
 
3668
  /**attempts to execute the Exclude_Indirect_From_Build stored procedure
-
 
3669
   * NB Execute_Indirect_From_Build will delete matching do_not_ripple rows prior to an insertion
-
 
3670
   * this is crucial!!
-
 
3671
   * 
-
 
3672
   * parameters:
-
 
3673
   * packageVersionId IN passed to Exclude_Indirect_From_Build 
-
 
3674
   * packageVersion   IN passed to Exclude_Indirect_From_Build 
-
 
3675
   * rtagId           IN passed to Exclude_Indirect_From_Build
-
 
3676
   * rootPvId         IN passed to Exclude_Indirect_From_Build
-
 
3677
   * rootCause        IN passed to Exclude_Indirect_From_Build
-
 
3678
   * rootFile         IN passed to Exclude_Indirect_From_Build
3670
  /**handles database connection/commit/disconnection when newSession is true
3679
   * newSession       IN handles database connection/commit/disconnection when true
3671
   * executes the Exclude_Indirect_From_Build stored procedure with the passed parameters
3680
   * supercede        IN checks for a row with a matching packageVersionId and rtagId when false
-
 
3681
   *                     such a row will prevent the execution of Exclude_Indirect_From_Build
-
 
3682
   * 
-
 
3683
   * returns:
-
 
3684
   * none
3672
   */
3685
   */
3673
  public void excludeFromBuild(String packageVersionId, 
3686
  public void excludeFromBuild(String packageVersionId, 
3674
                               String packageVersion, String rtagId, String rootPvId,
3687
                               String packageVersion, String rtagId, String rootPvId,
3675
                               String rootCause, String rootFile, boolean newSession) throws SQLException, Exception
3688
                               String rootCause, String rootFile, boolean newSession, boolean supercede) throws SQLException, Exception
3676
  {
3689
  {
3677
    mLogger.debug("excludeFromBuild " + packageVersionId);
3690
    mLogger.debug("excludeFromBuild " + packageVersionId);
3678
    if ( mUseDatabase )
3691
    if ( mUseDatabase )
3679
    {
3692
    {
3680
      try
3693
      try
Line 3684... Line 3697...
3684
          connect();
3697
          connect();
3685
        }
3698
        }
3686
        
3699
        
3687
        boolean exist = false;
3700
        boolean exist = false;
3688
        
3701
        
3689
        // do not exclude a package already excluded ie let the first build failure count
-
 
3690
        // there is a window of opportunity here, but it is worth doing
-
 
3691
        // scenario 1
-
 
3692
        // 1 this query indicates no build failure exists on this version
-
 
3693
        // 2 another build machine reports a build failure on this version
-
 
3694
        // 3 this is then overridden by this thread
-
 
3695
        // does not matter
-
 
3696
        // doing this works well for the following
-
 
3697
        // scenario 2
-
 
3698
        // 1 this query (run by a slave) indicates no build failure exists on this version
-
 
3699
        // 2 build failure is reported
-
 
3700
        // 3 master build machine detects slave in state waiting
-
 
3701
        // 4 master daemon discovers slave did not deliver artifacts
-
 
3702
        // 5 master daemon is prevented from overriding the build failure
-
 
3703
        CallableStatement stmt = mConnection.prepareCall("select pv_id from release_manager.do_not_ripple where pv_id=" + packageVersionId + "and rtag_id=" + rtagId);
-
 
3704
        ResultSet rset = stmt.executeQuery();
-
 
3705
        
-
 
3706
        while( rset.next() )
3702
        if ( !supercede )
3707
        {
3703
        {
-
 
3704
          // do not exclude a package already excluded ie let the first build failure count
-
 
3705
          // there is a window of opportunity here, but it is worth doing
-
 
3706
          // scenario 1
-
 
3707
          // 1 this query indicates no build failure exists on this version
-
 
3708
          // 2 another build machine reports a build failure on this version
-
 
3709
          // 3 this is then overridden by this thread
-
 
3710
          // does not matter
-
 
3711
          // doing this works well for the following
-
 
3712
          // scenario 2
-
 
3713
          // 1 this query (run by a slave) indicates no build failure exists on this version
-
 
3714
          // 2 build failure is reported
-
 
3715
          // 3 master build machine detects slave in state waiting
-
 
3716
          // 4 master daemon discovers slave did not deliver artifacts
-
 
3717
          // 5 master daemon is prevented from overriding the build failure
-
 
3718
          CallableStatement stmt = mConnection.prepareCall("select pv_id from release_manager.do_not_ripple where pv_id=" + packageVersionId + "and rtag_id=" + rtagId);
-
 
3719
          ResultSet rset = stmt.executeQuery();
-
 
3720
          
-
 
3721
          while( rset.next() )
-
 
3722
          {
3708
          exist = true;
3723
            exist = true;
3709
          break;
3724
            break;
-
 
3725
          }
-
 
3726
  
-
 
3727
          rset.close();
-
 
3728
          stmt.close();
3710
        }
3729
        }
3711
 
-
 
3712
        rset.close();
-
 
3713
        stmt.close();
-
 
3714
        
3730
        
3715
        if ( !exist )
3731
        if ( !exist )
3716
        {
3732
        {
3717
          stmt = mConnection.prepareCall( "begin ? := PK_RMAPI.EXCLUDE_INDIRECT_FROM_BUILD(?,?,?,?,?,?,?); end;" );
3733
          CallableStatement stmt = mConnection.prepareCall( "begin ? := PK_RMAPI.EXCLUDE_INDIRECT_FROM_BUILD(?,?,?,?,?,?,?); end;" );
3718
          stmt.registerOutParameter( 1, Types.INTEGER);
3734
          stmt.registerOutParameter( 1, Types.INTEGER);
3719
          stmt.setString( 2, packageVersionId );
3735
          stmt.setString( 2, packageVersionId );
3720
          stmt.setString( 3, packageVersion );
3736
          stmt.setString( 3, packageVersion );
3721
          stmt.setString( 4, rtagId );
3737
          stmt.setString( 4, rtagId );
3722
          stmt.setString( 5, "buildadm" );
3738
          stmt.setString( 5, "buildadm" );
Line 3968... Line 3984...
3968
    {
3984
    {
3969
      mLogger.info("connect !mUseDatabase");
3985
      mLogger.info("connect !mUseDatabase");
3970
    }
3986
    }
3971
    else
3987
    else
3972
    {
3988
    {
3973
      if ( !mRegistered )
-
 
3974
      {
-
 
3975
        try
-
 
3976
        {
-
 
3977
          // the JDBC driver is registered only once per database that needs to be accessed
-
 
3978
          mLogger.debug("connect registering driver");
-
 
3979
          DriverManager.registerDriver( new OracleDriver() );
-
 
3980
          mRegistered = true;
-
 
3981
        }
-
 
3982
        catch(SQLException e)
-
 
3983
        {
-
 
3984
          mLogger.fatal("connect failed to register the oracle jdbc driver with the driver manager");
-
 
3985
          throw new Exception("connect failed to register the oracle jdbc driver with the driver manager");
-
 
3986
        }
-
 
3987
      }
-
 
3988
 
-
 
3989
      // DEVI 46868
3989
      // DEVI 46868
3990
      // loop indefinitely until a connection attempt succeeds
3990
      // loop indefinitely until a connection attempt succeeds
3991
      // unless the failure is on the first attempt
3991
      // unless the failure is on the first attempt
3992
      boolean problemConnecting;
3992
      boolean problemConnecting;
3993
      
3993
      
Line 4000... Line 4000...
4000
        {
4000
        {
4001
          if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4001
          if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4002
          {
4002
          {
4003
            mLogger.warn("connect calling getConnection");
4003
            mLogger.warn("connect calling getConnection");
4004
            mConnection = DriverManager.getConnection(mConnectionString, mUsername, mPassword);
4004
            mConnection = DriverManager.getConnection(mConnectionString, mUsername, mPassword);
-
 
4005
            // when connection to the database is established, the connection, by default, is in auto-commit mode
-
 
4006
            // to adhere to the design in the use of select for update, it is crucial to turn auto-commit off
-
 
4007
            // this also improves performance
-
 
4008
            mConnection.setAutoCommit(false);
4005
          }
4009
          }
4006
        }
4010
        }
4007
        catch(SQLException e)
4011
        catch(SQLException e)
4008
        {
4012
        {
4009
          mLogger.warn("connect determined problem connecting");
4013
          mLogger.warn("connect determined problem connecting");