Subversion Repositories DevTools

Rev

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

Rev 896 Rev 898
Line 135... Line 135...
135
  /**set in claimVersion, cleared in discardVersion
135
  /**set in claimVersion, cleared in discardVersion
136
   * @attribute
136
   * @attribute
137
   */
137
   */
138
  private String mPlannedPkgId = null;
138
  private String mPlannedPkgId = null;
139
  
139
  
-
 
140
  /**prevents inadvertantly attempting a commit which releases record locks in between claimMutex and releaseMutex
-
 
141
   * @attribute
-
 
142
   */
-
 
143
  private boolean mDoNotCommit = false;
-
 
144
  
140
  /**set in claimVersion, cleared in discardVersion
145
  /**set in claimVersion, cleared in discardVersion
141
   * @attribute
146
   * @attribute
142
   */
147
   */
-
 
148
 
143
  private String mPlannedPkgVersion = null;
149
  private String mPlannedPkgVersion = null;
144
  
-
 
145
  /**in daemon mode
150
  /**in daemon mode
146
   *   select gm.gbe_value from release_manager.release_config rc, release_manager.gbe_machtype gm
151
   *   select gm.gbe_value from release_manager.release_config rc, release_manager.gbe_machtype gm
147
   *   where rc.rtag_id=<baseline> and gm.gbe_id=rc.gbe_id;
152
   *   where rc.rtag_id=<baseline> and gm.gbe_id=rc.gbe_id;
148
   * in escrow mode
153
   * in escrow mode
149
   *   select gm.gbe_value from deployment_manager.boms b, release_manager.release_config rc,
154
   *   select gm.gbe_value from deployment_manager.boms b, release_manager.release_config rc,
Line 3031... Line 3036...
3031
    mLogger.info("findPackage 2 returned " + retVal.mName);
3036
    mLogger.info("findPackage 2 returned " + retVal.mName);
3032
    return retVal;
3037
    return retVal;
3033
  }
3038
  }
3034
 
3039
 
3035
  /**essentially locks the row in the BUILD_SERVICE_CONFIG table with a service of MUTEX
3040
  /**essentially locks the row in the BUILD_SERVICE_CONFIG table with a service of MUTEX
3036
   * for the duration of the connection
3041
   * for the duration of the transaction
3037
   * this prevents other MasterThreads from generating build files in parallel
3042
   * this prevents other MasterThreads from generating build files in parallel
3038
   * and hence prevents planned version numbering contention
3043
   * and hence prevents planned version numbering contention
3039
   * select CONFIG from release_manager.BUILD_SERVICE_CONFIG WHERE SERVICE='MUTEX' FOR UPDATE
3044
   * select CONFIG from release_manager.BUILD_SERVICE_CONFIG WHERE SERVICE='MUTEX' FOR UPDATE
3040
   */
3045
   */
3041
  public void claimMutex() throws SQLException, Exception
3046
  public void claimMutex() throws SQLException, Exception
Line 3046... Line 3051...
3046
      try
3051
      try
3047
      {
3052
      {
3048
        CallableStatement stmt = mConnection.prepareCall("select CONFIG from release_manager.BUILD_SERVICE_CONFIG WHERE SERVICE='MUTEX' FOR UPDATE");
3053
        CallableStatement stmt = mConnection.prepareCall("select CONFIG from release_manager.BUILD_SERVICE_CONFIG WHERE SERVICE='MUTEX' FOR UPDATE");
3049
        stmt.executeUpdate();
3054
        stmt.executeUpdate();
3050
        stmt.close();
3055
        stmt.close();
-
 
3056
        mDoNotCommit = true;
3051
      }
3057
      }
3052
      catch ( SQLException e )
3058
      catch ( SQLException e )
3053
      {
3059
      {
3054
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3060
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3055
        {
3061
        {
Line 3065... Line 3071...
3065
      // about to start the planning process again, discard previous
3071
      // about to start the planning process again, discard previous
3066
      discardVersions();
3072
      discardVersions();
3067
    }
3073
    }
3068
  }
3074
  }
3069
 
3075
 
-
 
3076
  /**essentially unlocks the row in the BUILD_SERVICE_CONFIG table with a service of MUTEX
-
 
3077
   */
-
 
3078
  public void releaseMutex() throws SQLException, Exception
-
 
3079
  {
-
 
3080
    mLogger.debug("releaseMutex");
-
 
3081
    if ( mUseDatabase )
-
 
3082
    {
-
 
3083
      try
-
 
3084
      {
-
 
3085
        mDoNotCommit = false;
-
 
3086
        commit();
-
 
3087
      }
-
 
3088
      catch ( SQLException e )
-
 
3089
      {
-
 
3090
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
-
 
3091
        {
-
 
3092
          mLogger.error("releaseMutex database access error only");
-
 
3093
          throw new SQLException();
-
 
3094
        }
-
 
3095
        else
-
 
3096
        {
-
 
3097
          mLogger.fatal("releaseMutex show stopper");
-
 
3098
          throw new Exception("releaseMutex show stopper");
-
 
3099
        }
-
 
3100
      }
-
 
3101
    }
-
 
3102
  }
-
 
3103
 
-
 
3104
  /**central commit protection
-
 
3105
   */
-
 
3106
  private void commit() throws SQLException, Exception
-
 
3107
  {
-
 
3108
    mLogger.debug("commit");
-
 
3109
    if ( mUseDatabase )
-
 
3110
    {
-
 
3111
      if ( mDoNotCommit )
-
 
3112
      {
-
 
3113
        mLogger.error("commit attempted commit with mDoNotCommit set, this is a programming error");
-
 
3114
      }
-
 
3115
      else
-
 
3116
      {
-
 
3117
        mConnection.commit();
-
 
3118
      }
-
 
3119
    }
-
 
3120
  }
-
 
3121
 
3070
  /**sets CURRENT_BUILD_FILES to NULL for the rcon_id
3122
  /**sets CURRENT_BUILD_FILES to NULL for the rcon_id
3071
   * update release_manager.run_level set current_build_files=null where rcon_id=<rcon_id>
3123
   * update release_manager.run_level set current_build_files=null where rcon_id=<rcon_id>
3072
   */
3124
   */
3073
  public void clearBuildFile(int rcon_id) throws SQLException, Exception
3125
  public void clearBuildFile(int rcon_id) throws SQLException, Exception
3074
  {
3126
  {
Line 3081... Line 3133...
3081
      if ( isRconIdConfigured( rcon_id ))
3133
      if ( isRconIdConfigured( rcon_id ))
3082
      {
3134
      {
3083
        CallableStatement stmt = mConnection.prepareCall("update release_manager.run_level set current_build_files=null where rcon_id=" + rcon_id);
3135
        CallableStatement stmt = mConnection.prepareCall("update release_manager.run_level set current_build_files=null where rcon_id=" + rcon_id);
3084
        stmt.executeUpdate();
3136
        stmt.executeUpdate();
3085
        stmt.close();
3137
        stmt.close();
3086
        mConnection.commit();
-
 
3087
        disconnect();
3138
        commit();
3088
      }
3139
      }
3089
    }
3140
    }
3090
    catch ( SQLException e )
3141
    catch ( SQLException e )
3091
    {
3142
    {
3092
      if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3143
      if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
Line 3098... Line 3149...
3098
      {
3149
      {
3099
        mLogger.fatal("clearBuildFile show stopper");
3150
        mLogger.fatal("clearBuildFile show stopper");
3100
        throw new Exception("clearBuildFile show stopper");
3151
        throw new Exception("clearBuildFile show stopper");
3101
      }
3152
      }
3102
    }
3153
    }
-
 
3154
    finally
-
 
3155
    {
-
 
3156
      // this block is executed regardless of what happens in the try block
-
 
3157
      // even if an exception is thrown
-
 
3158
      // ensure disconnect
-
 
3159
      disconnect();
-
 
3160
    }
3103
  }
3161
  }
3104
 
3162
 
3105
  /**updates the CURRENT_BUILD_FILES for the rtag_id
3163
  /**updates the CURRENT_BUILD_FILES for the rtag_id
3106
   * update (
3164
   * update (
3107
   * select current_build_files from release_manager.release_manager.run_level rl, release_manager.release_manager.release_config rc
3165
   * select current_build_files from release_manager.release_manager.run_level rl, release_manager.release_manager.release_config rc
Line 3124... Line 3182...
3124
        "where rc.rtag_id=? and rl.rcon_id=rc.rcon_id" +
3182
        "where rc.rtag_id=? and rl.rcon_id=rc.rcon_id" +
3125
        ") set current_build_files=?");
3183
        ") set current_build_files=?");
3126
        stmt.setInt(1, rtag_id);
3184
        stmt.setInt(1, rtag_id);
3127
        stmt.setString(2, buildFile);
3185
        stmt.setString(2, buildFile);
3128
        stmt.executeUpdate();
3186
        stmt.executeUpdate();
3129
        mConnection.commit();
-
 
3130
        stmt.close();
3187
        stmt.close();
3131
        disconnect();
3188
        commit();
3132
      }
3189
      }
3133
    }
3190
    }
3134
    catch ( SQLException e )
3191
    catch ( SQLException e )
3135
    {
3192
    {
3136
      if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3193
      if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
Line 3149... Line 3206...
3149
      // this catch and rethrow is historical
3206
      // this catch and rethrow is historical
3150
      // problems were found using CallableStatement when updating a CLOB column with data > 4000 bytes
3207
      // problems were found using CallableStatement when updating a CLOB column with data > 4000 bytes
3151
      mLogger.fatal("publishBuildFile caught Exception " + e.getMessage());
3208
      mLogger.fatal("publishBuildFile caught Exception " + e.getMessage());
3152
      throw new Exception("publishBuildFile caught Exception " + e.getMessage());
3209
      throw new Exception("publishBuildFile caught Exception " + e.getMessage());
3153
    }
3210
    }
-
 
3211
    finally
-
 
3212
    {
-
 
3213
      // this block is executed regardless of what happens in the try block
-
 
3214
      // even if an exception is thrown
-
 
3215
      // ensure disconnect
-
 
3216
      disconnect();
-
 
3217
    }
3154
  }
3218
  }
3155
 
3219
 
3156
  /**ensures a run_level_schedule row with a non null indefinite_pause column exists
3220
  /**ensures a run_level_schedule row with a non null indefinite_pause column exists
3157
   * this is aimed at stopping all daemons dead
3221
   * this is aimed at stopping all daemons dead
3158
   * it is raised when handling an unsupported exception case in either the main or slave daemons
3222
   * it is raised when handling an unsupported exception case in either the main or slave daemons
Line 3167... Line 3231...
3167
      {
3231
      {
3168
        connect();
3232
        connect();
3169
        CallableStatement stmt = mConnection.prepareCall( "begin PK_BUILDAPI.SET_INFINITE_PAUSE(); end;" );
3233
        CallableStatement stmt = mConnection.prepareCall( "begin PK_BUILDAPI.SET_INFINITE_PAUSE(); end;" );
3170
        stmt.executeUpdate();
3234
        stmt.executeUpdate();
3171
        stmt.close();
3235
        stmt.close();
3172
        mConnection.commit();
-
 
3173
        disconnect();
3236
        commit();
3174
      }
3237
      }
3175
      catch( SQLException e )
3238
      catch( SQLException e )
3176
      {
3239
      {
3177
        // do not throw Exception
3240
        // do not throw Exception
3178
        // this is part of Exception handling
3241
        // this is part of Exception handling
Line 3180... Line 3243...
3180
      }
3243
      }
3181
      catch( Exception e )
3244
      catch( Exception e )
3182
      {
3245
      {
3183
        mLogger.fatal( "indefinitePause caught Exception " + e.getMessage() );
3246
        mLogger.fatal( "indefinitePause caught Exception " + e.getMessage() );
3184
      }
3247
      }
-
 
3248
      finally
-
 
3249
      {
-
 
3250
        // this block is executed regardless of what happens in the try block
-
 
3251
        // even if an exception is thrown
-
 
3252
        // ensure disconnect
-
 
3253
        try
-
 
3254
        {
-
 
3255
          disconnect();
-
 
3256
        }
-
 
3257
        catch( SQLException e )
-
 
3258
        {
-
 
3259
          // do not throw Exception
-
 
3260
          // this is part of Exception handling
-
 
3261
          mLogger.fatal( "indefinitePause2 caught SQLException " + e.getMessage() );
-
 
3262
        }
-
 
3263
        catch( Exception e )
-
 
3264
        {
-
 
3265
          mLogger.fatal( "indefinitePause2 caught Exception " + e.getMessage() );
-
 
3266
        }
-
 
3267
      }
3185
    }
3268
    }
3186
  }
3269
  }
3187
 
3270
 
3188
  /**ensures a run_level_schedule row with a non null indefinite_pause column does not exist
3271
  /**ensures a run_level_schedule row with a non null indefinite_pause column does not exist
3189
   * this is aimed at resuming all daemons
3272
   * this is aimed at resuming all daemons
Line 3196... Line 3279...
3196
      try
3279
      try
3197
      {
3280
      {
3198
        CallableStatement stmt = mConnection.prepareCall( "begin PK_BUILDAPI.SET_RESUME(); end;" );
3281
        CallableStatement stmt = mConnection.prepareCall( "begin PK_BUILDAPI.SET_RESUME(); end;" );
3199
        stmt.executeUpdate();
3282
        stmt.executeUpdate();
3200
        stmt.close();
3283
        stmt.close();
3201
        mConnection.commit();
3284
        commit();
3202
      }
3285
      }
3203
      catch ( SQLException e )
3286
      catch ( SQLException e )
3204
      {
3287
      {
3205
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3288
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3206
        {
3289
        {
Line 3329... Line 3412...
3329
          "where rc.rtag_id=" + rtag_id + " and rl.rcon_id=rc.rcon_id" +
3412
          "where rc.rtag_id=" + rtag_id + " and rl.rcon_id=rc.rcon_id" +
3330
          ")" +
3413
          ")" +
3331
          "set current_pkg_id_being_built=" + pkg_id);
3414
          "set current_pkg_id_being_built=" + pkg_id);
3332
          stmt4.executeUpdate();
3415
          stmt4.executeUpdate();
3333
          stmt4.close();
3416
          stmt4.close();
3334
          mConnection.commit();
-
 
3335
          mPlannedPkgId = new String();
3417
          mPlannedPkgId = new String();
3336
          mPlannedPkgId += pkg_id;
3418
          mPlannedPkgId += pkg_id;
3337
          mPlannedPkgVersion = new String( pkg_version );
3419
          mPlannedPkgVersion = new String( pkg_version );
3338
        }
3420
        }
3339
      }
3421
      }
Line 3364... Line 3446...
3364
      try
3446
      try
3365
      {
3447
      {
3366
        CallableStatement stmt = mConnection.prepareCall("delete from release_manager.planned_versions where pkg_id=" + mPlannedPkgId + " and pkg_version='" + mPlannedPkgVersion + "'");
3448
        CallableStatement stmt = mConnection.prepareCall("delete from release_manager.planned_versions where pkg_id=" + mPlannedPkgId + " and pkg_version='" + mPlannedPkgVersion + "'");
3367
        stmt.executeUpdate();
3449
        stmt.executeUpdate();
3368
        stmt.close();
3450
        stmt.close();
3369
        mConnection.commit();
3451
        commit();
3370
        mPlannedPkgId = null;
3452
        mPlannedPkgId = null;
3371
        mPlannedPkgVersion = null;
3453
        mPlannedPkgVersion = null;
3372
      }
3454
      }
3373
      catch ( SQLException e )
3455
      catch ( SQLException e )
3374
      {
3456
      {
Line 3400... Line 3482...
3400
      // trunc(sysdate, 'hh') - 1 returns the time 24 hours ago rounded to the nearest hour
3482
      // trunc(sysdate, 'hh') - 1 returns the time 24 hours ago rounded to the nearest hour
3401
      // this statement does not return any rows when planned_time is null, though this should never be the case
3483
      // this statement does not return any rows when planned_time is null, though this should never be the case
3402
      CallableStatement stmt = mConnection.prepareCall("delete from release_manager.planned_versions where planned_time < trunc(sysdate, 'hh') - 1");
3484
      CallableStatement stmt = mConnection.prepareCall("delete from release_manager.planned_versions where planned_time < trunc(sysdate, 'hh') - 1");
3403
      stmt.executeUpdate();
3485
      stmt.executeUpdate();
3404
      stmt.close();
3486
      stmt.close();
3405
      mConnection.commit();
-
 
3406
    }
3487
    }
3407
    catch ( SQLException e )
3488
    catch ( SQLException e )
3408
    {
3489
    {
3409
      if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3490
      if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3410
      {
3491
      {
Line 3445... Line 3526...
3445
          "where rcon_id=" + rcon_id +
3526
          "where rcon_id=" + rcon_id +
3446
          ")" +
3527
          ")" +
3447
          "set current_pkg_id_being_built=null" );
3528
          "set current_pkg_id_being_built=null" );
3448
          stmt4.executeUpdate();
3529
          stmt4.executeUpdate();
3449
          stmt4.close();
3530
          stmt4.close();
3450
          mConnection.commit();
3531
          commit();
3451
        }
3532
        }
3452
        disconnect();
-
 
3453
      }
3533
      }
3454
      catch ( SQLException e )
3534
      catch ( SQLException e )
3455
      {
3535
      {
3456
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3536
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3457
        {
3537
        {
Line 3462... Line 3542...
3462
        {
3542
        {
3463
          mLogger.fatal("clearCurrentPackageBeingBuilt show stopper");
3543
          mLogger.fatal("clearCurrentPackageBeingBuilt show stopper");
3464
          throw new Exception("clearCurrentPackageBeingBuilt show stopper");
3544
          throw new Exception("clearCurrentPackageBeingBuilt show stopper");
3465
        }
3545
        }
3466
      }
3546
      }
-
 
3547
      finally
-
 
3548
      {
-
 
3549
        // this block is executed regardless of what happens in the try block
-
 
3550
        // even if an exception is thrown
-
 
3551
        // ensure disconnect
-
 
3552
        disconnect();
-
 
3553
      }
3467
    }
3554
    }
3468
  }
3555
  }
3469
 
3556
 
3470
  /**handles database connection/disconnection
3557
  /**handles database connection/disconnection
3471
   * executes the AutoMakeRelease stored procedure with the passed parameters
3558
   * executes the AutoMakeRelease stored procedure with the passed parameters
Line 3500... Line 3587...
3500
          // flag build failure
3587
          // flag build failure
3501
          mLogger.fatal("autoMakeRelease show stopper PK_RMAPI.AUTO_MAKE_RELEASE failed, returned" + result);
3588
          mLogger.fatal("autoMakeRelease show stopper PK_RMAPI.AUTO_MAKE_RELEASE failed, returned" + result);
3502
          throw new Exception("autoMakeRelease show stopper PK_RMAPI.AUTO_MAKE_RELEASE failed, returned" + result);
3589
          throw new Exception("autoMakeRelease show stopper PK_RMAPI.AUTO_MAKE_RELEASE failed, returned" + result);
3503
        }
3590
        }
3504
        stmt.close();
3591
        stmt.close();
3505
        mConnection.commit();
-
 
3506
        disconnect();
3592
        commit();
3507
      }
3593
      }
3508
      catch( SQLException e )
3594
      catch( SQLException e )
3509
      {
3595
      {
3510
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3596
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3511
        {
3597
        {
Line 3516... Line 3602...
3516
        {
3602
        {
3517
          mLogger.fatal("autoMakeRelease show stopper");
3603
          mLogger.fatal("autoMakeRelease show stopper");
3518
          throw new Exception("autoMakeRelease show stopper");
3604
          throw new Exception("autoMakeRelease show stopper");
3519
        }
3605
        }
3520
      }
3606
      }
-
 
3607
      finally
-
 
3608
      {
-
 
3609
        // this block is executed regardless of what happens in the try block
-
 
3610
        // even if an exception is thrown
-
 
3611
        // ensure disconnect
-
 
3612
        disconnect();
-
 
3613
      }
3521
    }
3614
    }
3522
  }
3615
  }
3523
 
3616
 
3524
  /**handles database connection/disconnection
3617
  /**handles database connection/disconnection
3525
   * executes the insertPackageMetrics stored procedure with the passed parameters
3618
   * executes the insertPackageMetrics stored procedure with the passed parameters
Line 3547... Line 3640...
3547
          // flag build failure
3640
          // flag build failure
3548
          mLogger.fatal("insertPackageMetrics show stopper PK_RMAPI.INSERT_PACKAGE_METRICS failed, returned" + result);
3641
          mLogger.fatal("insertPackageMetrics show stopper PK_RMAPI.INSERT_PACKAGE_METRICS failed, returned" + result);
3549
          throw new Exception("insertPackageMetrics show stopper PK_RMAPI.INSERT_PACKAGE_METRICS failed, returned" + result);
3642
          throw new Exception("insertPackageMetrics show stopper PK_RMAPI.INSERT_PACKAGE_METRICS failed, returned" + result);
3550
        }
3643
        }
3551
        stmt.close();
3644
        stmt.close();
3552
        mConnection.commit();
-
 
3553
        disconnect();
3645
        commit();
3554
      }
3646
      }
3555
      catch( SQLException e )
3647
      catch( SQLException e )
3556
      {
3648
      {
3557
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3649
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3558
        {
3650
        {
Line 3563... Line 3655...
3563
        {
3655
        {
3564
          mLogger.fatal("insertPackageMetrics show stopper");
3656
          mLogger.fatal("insertPackageMetrics show stopper");
3565
          throw new Exception("insertPackageMetrics show stopper");
3657
          throw new Exception("insertPackageMetrics show stopper");
3566
        }
3658
        }
3567
      }
3659
      }
-
 
3660
      finally
-
 
3661
      {
-
 
3662
        // this block is executed regardless of what happens in the try block
-
 
3663
        // even if an exception is thrown
-
 
3664
        // ensure disconnect
-
 
3665
        disconnect();
-
 
3666
      }
3568
    }
3667
    }
3569
  }
3668
  }
3570
 
3669
 
3571
  /**handles database connection/disconnection
3670
  /**handles database connection/commit/disconnection when newSession is true
3572
   * executes the Exclude_Indirect_From_Build stored procedure with the passed parameters
3671
   * executes the Exclude_Indirect_From_Build stored procedure with the passed parameters
3573
   */
3672
   */
3574
  public void excludeFromBuild(String packageVersionId, 
3673
  public void excludeFromBuild(String packageVersionId, 
3575
                               String packageVersion, String rtagId, String rootPvId,
3674
                               String packageVersion, String rtagId, String rootPvId,
3576
                               String rootCause, String rootFile) throws SQLException, Exception
3675
                               String rootCause, String rootFile, boolean newSession) throws SQLException, Exception
3577
  {
3676
  {
3578
    mLogger.debug("excludeFromBuild " + packageVersionId);
3677
    mLogger.debug("excludeFromBuild " + packageVersionId);
3579
    if ( mUseDatabase )
3678
    if ( mUseDatabase )
3580
    {
3679
    {
3581
      try
3680
      try
3582
      {
3681
      {
-
 
3682
        if ( newSession )
-
 
3683
        {
3583
        connect();
3684
          connect();
-
 
3685
        }
-
 
3686
        
3584
        boolean exist = false;
3687
        boolean exist = false;
3585
        
3688
        
3586
        // do not exclude a package already excluded ie let the first build failure count
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
3587
        CallableStatement stmt = mConnection.prepareCall("select pv_id from release_manager.do_not_ripple where pv_id=" + packageVersionId + "and rtag_id=" + rtagId);
3703
        CallableStatement stmt = mConnection.prepareCall("select pv_id from release_manager.do_not_ripple where pv_id=" + packageVersionId + "and rtag_id=" + rtagId);
3588
        ResultSet rset = stmt.executeQuery();
3704
        ResultSet rset = stmt.executeQuery();
3589
        
3705
        
3590
        while( rset.next() )
3706
        while( rset.next() )
3591
        {
3707
        {
Line 3615... Line 3731...
3615
            // flag build failure
3731
            // flag build failure
3616
            mLogger.fatal( "excludeFromBuild show stopper PK_RMAPI.EXCLUDE_INDIRECT_FROM_BUILD failed, returned " + result );
3732
            mLogger.fatal( "excludeFromBuild show stopper PK_RMAPI.EXCLUDE_INDIRECT_FROM_BUILD failed, returned " + result );
3617
            throw new Exception("excludeFromBuild show stopper PK_RMAPI.EXCLUDE_INDIRECT_FROM_BUILD failed, returned " + result);
3733
            throw new Exception("excludeFromBuild show stopper PK_RMAPI.EXCLUDE_INDIRECT_FROM_BUILD failed, returned " + result);
3618
          }
3734
          }
3619
          stmt.close();
3735
          stmt.close();
-
 
3736
          
-
 
3737
          if ( newSession )
-
 
3738
          {
3620
          mConnection.commit();
3739
            commit();
-
 
3740
          }
3621
        }
3741
        }
3622
        disconnect();
-
 
3623
      }
3742
      }
3624
      catch( SQLException e )
3743
      catch( SQLException e )
3625
      {
3744
      {
3626
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3745
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3627
        {
3746
        {
Line 3632... Line 3751...
3632
        {
3751
        {
3633
          mLogger.fatal("excludeFromBuild show stopper");
3752
          mLogger.fatal("excludeFromBuild show stopper");
3634
          throw new Exception("excludeFromBuild show stopper");
3753
          throw new Exception("excludeFromBuild show stopper");
3635
        }
3754
        }
3636
      }
3755
      }
-
 
3756
      finally
-
 
3757
      {
-
 
3758
        // this block is executed regardless of what happens in the try block
-
 
3759
        // even if an exception is thrown
-
 
3760
        // ensure disconnect
-
 
3761
        if ( newSession )
-
 
3762
        {
-
 
3763
          disconnect();
-
 
3764
        }
-
 
3765
      }
3637
    }
3766
    }
3638
  }
3767
  }
3639
 
3768
 
3640
  /**removes an excluded package from the do_not_ripple table
3769
  /**removes an excluded package from the do_not_ripple table
3641
   */
3770
   */
Line 3647... Line 3776...
3647
      try
3776
      try
3648
      {
3777
      {
3649
        CallableStatement stmt = mConnection.prepareCall("delete from release_manager.do_not_ripple where rtag_id=" + rtagId + " and pv_id=" + packageVersionId);
3778
        CallableStatement stmt = mConnection.prepareCall("delete from release_manager.do_not_ripple where rtag_id=" + rtagId + " and pv_id=" + packageVersionId);
3650
        stmt.executeUpdate();
3779
        stmt.executeUpdate();
3651
        stmt.close();
3780
        stmt.close();
3652
        mConnection.commit();
-
 
3653
      }
3781
      }
3654
      catch( SQLException e )
3782
      catch( SQLException e )
3655
      {
3783
      {
3656
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3784
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3657
        {
3785
        {
Line 3820... Line 3948...
3820
  /**connect to oracle
3948
  /**connect to oracle
3821
   */
3949
   */
3822
  public void connect() throws SQLException, Exception
3950
  public void connect() throws SQLException, Exception
3823
  {
3951
  {
3824
    mLogger.debug("connect");
3952
    mLogger.debug("connect");
-
 
3953
    
-
 
3954
    if ( mSession.isHeldByCurrentThread() )
-
 
3955
    {
-
 
3956
      // by design a thread must NOT connect multiple times
-
 
3957
      // this is to ensure the lock is claimed only once
-
 
3958
      mLogger.error("connect thread already has the lock");
-
 
3959
    }
-
 
3960
    else
-
 
3961
    {
-
 
3962
      mLogger.warn("connect calling lock");
3825
    mSession.lock();
3963
      mSession.lock();
-
 
3964
      mLogger.warn("connect called lock");
-
 
3965
    }
3826
    
3966
    
3827
    if ( !mUseDatabase )
3967
    if ( !mUseDatabase )
3828
    {
3968
    {
3829
      mLogger.info("connect !mUseDatabase");
3969
      mLogger.info("connect !mUseDatabase");
3830
    }
3970
    }
Line 3909... Line 4049...
3909
      {
4049
      {
3910
        mLogger.error("disconnect caught Exception");
4050
        mLogger.error("disconnect caught Exception");
3911
        throw new Exception();
4051
        throw new Exception();
3912
      }
4052
      }
3913
    }*/
4053
    }*/
-
 
4054
    
-
 
4055
    // by design, a thread may call disconnect multiple times
-
 
4056
    // this is a technique used in finally blocks
-
 
4057
    // it is to ensure the lock is released in all cases
-
 
4058
    // only unlock if it is held by this thread
-
 
4059
    // when unlock is called on a ReentrantLock held by this thread
-
 
4060
    // the hold count is decremented
-
 
4061
    // connect should only let the hold count be incremented to 1
-
 
4062
    // when the hold count is 0 the lock is released
-
 
4063
    // and the ReentrantLock is no longer held by this thread
-
 
4064
    // only call unlock when the lock is held by this thread
-
 
4065
    if ( mSession.isHeldByCurrentThread() )
-
 
4066
    {
-
 
4067
      mLogger.warn("disconnected calling unlock");
3914
    mSession.unlock();
4068
      mSession.unlock();
-
 
4069
      mLogger.warn("disconnected called unlock");
-
 
4070
    }
3915
  }
4071
  }
3916
 
4072
 
3917
  /**returns true if the mReleaseConfigCollection is not empty and returns the rcon_id of the first element
4073
  /**returns true if the mReleaseConfigCollection is not empty and returns the rcon_id of the first element
3918
   */
4074
   */
3919
  public boolean getFirstReleaseConfig(MutableInt rcon_id)
4075
  public boolean getFirstReleaseConfig(MutableInt rcon_id)
Line 4203... Line 4359...
4203
    }
4359
    }
4204
    else
4360
    else
4205
    {
4361
    {
4206
      try
4362
      try
4207
      {
4363
      {
-
 
4364
        connect();
4208
        String sql = new String("select gbe_buildfilter from release_manager.release_config where rcon_id=" + rcon_id );
4365
        String sql = new String("select gbe_buildfilter from release_manager.release_config where rcon_id=" + rcon_id );
4209
        CallableStatement stmt = mConnection.prepareCall( sql );
4366
        CallableStatement stmt = mConnection.prepareCall( sql );
4210
        ResultSet rset = stmt.executeQuery();
4367
        ResultSet rset = stmt.executeQuery();
4211
        int rsetSize = 0;
4368
        int rsetSize = 0;
4212
        
4369
        
Line 4237... Line 4394...
4237
        {
4394
        {
4238
          mLogger.fatal("queryBuildFilter show stopper");
4395
          mLogger.fatal("queryBuildFilter show stopper");
4239
          throw new Exception("queryBuildFilter show stopper");
4396
          throw new Exception("queryBuildFilter show stopper");
4240
        }
4397
        }
4241
      }
4398
      }
-
 
4399
      finally
-
 
4400
      {
-
 
4401
        // this block is executed regardless of what happens in the try block
-
 
4402
        // even if an exception is thrown
-
 
4403
        // ensure disconnect
-
 
4404
        disconnect();
-
 
4405
      }
4242
    }
4406
    }
4243
  }
4407
  }
4244
 
4408
 
4245
  /**removes all elements from the mReleaseConfigCollection
4409
  /**removes all elements from the mReleaseConfigCollection
4246
   * handles database connection and disconnection
4410
   * handles database connection and disconnection
Line 4299... Line 4463...
4299
        }
4463
        }
4300
        
4464
        
4301
        
4465
        
4302
        rset.close();
4466
        rset.close();
4303
        stmt.close();
4467
        stmt.close();
4304
        disconnect();
-
 
4305
      }
4468
      }
4306
      catch ( SQLException e )
4469
      catch ( SQLException e )
4307
      {
4470
      {
4308
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4471
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4309
        {
4472
        {
Line 4314... Line 4477...
4314
        {
4477
        {
4315
          mLogger.fatal("queryReleaseConfig 2 show stopper");
4478
          mLogger.fatal("queryReleaseConfig 2 show stopper");
4316
          throw new Exception("queryReleaseConfig 2 show stopper");
4479
          throw new Exception("queryReleaseConfig 2 show stopper");
4317
        }
4480
        }
4318
      }
4481
      }
-
 
4482
      finally
-
 
4483
      {
-
 
4484
        // this block is executed regardless of what happens in the try block
-
 
4485
        // even if an exception is thrown
-
 
4486
        // ensure disconnect
-
 
4487
        disconnect();
-
 
4488
      }
4319
    }
4489
    }
4320
  }
4490
  }
4321
 
4491
 
4322
  /**removes all elements from the mReleaseConfigCollection
4492
  /**removes all elements from the mReleaseConfigCollection
4323
   * handles database connection and disconnection
4493
   * handles database connection and disconnection
Line 4384... Line 4554...
4384
          mReleaseConfigCollection.add(releaseConfig);
4554
          mReleaseConfigCollection.add(releaseConfig);
4385
        }
4555
        }
4386
        
4556
        
4387
        rset.close();
4557
        rset.close();
4388
        stmt.close();
4558
        stmt.close();
4389
        disconnect();
-
 
4390
      }
4559
      }
4391
      catch ( SQLException e )
4560
      catch ( SQLException e )
4392
      {
4561
      {
4393
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4562
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4394
        {
4563
        {
Line 4399... Line 4568...
4399
        {
4568
        {
4400
          mLogger.fatal("queryReleaseConfig 3 show stopper");
4569
          mLogger.fatal("queryReleaseConfig 3 show stopper");
4401
          throw new Exception("queryReleaseConfig 3 show stopper");
4570
          throw new Exception("queryReleaseConfig 3 show stopper");
4402
        }
4571
        }
4403
      }
4572
      }
-
 
4573
      finally
-
 
4574
      {
-
 
4575
        // this block is executed regardless of what happens in the try block
-
 
4576
        // even if an exception is thrown
-
 
4577
        // ensure disconnect
-
 
4578
        disconnect();
-
 
4579
      }
4404
    }
4580
    }
4405
  }
4581
  }
4406
 
4582
 
4407
  /**queries the RUN_LEVEL table using the rcon_id primary key
4583
  /**queries the RUN_LEVEL table using the rcon_id primary key
4408
   * handles database connection and disconnection
4584
   * handles database connection and disconnection
Line 4443... Line 4619...
4443
          throw new Exception("queryRunLevel 1 rsetSize > 1");
4619
          throw new Exception("queryRunLevel 1 rsetSize > 1");
4444
        }
4620
        }
4445
        
4621
        
4446
        rset.close();
4622
        rset.close();
4447
        stmt.close();
4623
        stmt.close();
4448
        disconnect();
-
 
4449
      }
4624
      }
4450
      catch ( SQLException e )
4625
      catch ( SQLException e )
4451
      {
4626
      {
4452
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4627
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4453
        {
4628
        {
Line 4458... Line 4633...
4458
        {
4633
        {
4459
          mLogger.fatal("queryRunLevel 1 show stopper");
4634
          mLogger.fatal("queryRunLevel 1 show stopper");
4460
          throw new Exception("queryRunLevel 1 show stopper");
4635
          throw new Exception("queryRunLevel 1 show stopper");
4461
        }
4636
        }
4462
      }
4637
      }
-
 
4638
      finally
-
 
4639
      {
-
 
4640
        // this block is executed regardless of what happens in the try block
-
 
4641
        // even if an exception is thrown
-
 
4642
        // ensure disconnect
-
 
4643
        disconnect();
-
 
4644
      }
4463
    }
4645
    }
4464
  }
4646
  }
4465
 
4647
 
4466
  /**removes all elements from the mRunLevelCollection
4648
  /**removes all elements from the mRunLevelCollection
4467
   * handles database connection and disconnection
4649
   * handles database connection and disconnection
Line 4536... Line 4718...
4536
          mRunLevelCollection.add(runLevel);
4718
          mRunLevelCollection.add(runLevel);
4537
        }
4719
        }
4538
 
4720
 
4539
        rset.close();
4721
        rset.close();
4540
        stmt.close();
4722
        stmt.close();
4541
        disconnect();
-
 
4542
      }
4723
      }
4543
      catch ( SQLException e )
4724
      catch ( SQLException e )
4544
      {
4725
      {
4545
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4726
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4546
        {
4727
        {
Line 4551... Line 4732...
4551
        {
4732
        {
4552
          mLogger.fatal("queryRunLevel 2 show stopper");
4733
          mLogger.fatal("queryRunLevel 2 show stopper");
4553
          throw new Exception("queryRunLevel 2 show stopper");
4734
          throw new Exception("queryRunLevel 2 show stopper");
4554
        }
4735
        }
4555
      }
4736
      }
-
 
4737
      finally
4556
      
4738
      {
-
 
4739
        // this block is executed regardless of what happens in the try block
-
 
4740
        // even if an exception is thrown
-
 
4741
        // ensure disconnect
-
 
4742
        disconnect();
4557
 
4743
      }
4558
    }
4744
    }
4559
  }
4745
  }
4560
 
4746
 
4561
  /**removes all elements from the mRunLevelCollection
4747
  /**removes all elements from the mRunLevelCollection
4562
   * handles database connection and disconnection
4748
   * handles database connection and disconnection
Line 4616... Line 4802...
4616
            mLogger.fatal("querySingleRunLevel rsetSize != 1");
4802
            mLogger.fatal("querySingleRunLevel rsetSize != 1");
4617
            // show stopper
4803
            // show stopper
4618
            throw new Exception("querySingleRunLevel rsetSize != 1");
4804
            throw new Exception("querySingleRunLevel rsetSize != 1");
4619
          }
4805
          }
4620
        }
4806
        }
4621
        
-
 
4622
        disconnect();
-
 
4623
      }
4807
      }
4624
      catch ( SQLException e )
4808
      catch ( SQLException e )
4625
      {
4809
      {
4626
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4810
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4627
        {
4811
        {
Line 4632... Line 4816...
4632
        {
4816
        {
4633
          mLogger.fatal("querySingleRunLevel show stopper");
4817
          mLogger.fatal("querySingleRunLevel show stopper");
4634
          throw new Exception("querySingleRunLevel show stopper");
4818
          throw new Exception("querySingleRunLevel show stopper");
4635
        }
4819
        }
4636
      }
4820
      }
-
 
4821
      finally
-
 
4822
      {
-
 
4823
        // this block is executed regardless of what happens in the try block
-
 
4824
        // even if an exception is thrown
-
 
4825
        // ensure disconnect
-
 
4826
        disconnect();
-
 
4827
      }
4637
    }
4828
    }
4638
  }
4829
  }
4639
 
4830
 
4640
  /**queries the RUN_LEVEL_SCHEDULE table
4831
  /**queries the RUN_LEVEL_SCHEDULE table
4641
   * when recover is true, checks for archive existence and runs resume when both archives exist
4832
   * when recover is true, checks for archive existence and runs resume when both archives exist
Line 4956... Line 5147...
4956
          // DEVI 52589 provide a keep alive indication
5147
          // DEVI 52589 provide a keep alive indication
4957
          PreparedStatement stmt = mConnection.prepareCall("update release_manager.run_level set current_run_level=" + runLevel + ", keep_alive=SYSDATE where rcon_id=" + rcon_id);
5148
          PreparedStatement stmt = mConnection.prepareCall("update release_manager.run_level set current_run_level=" + runLevel + ", keep_alive=SYSDATE where rcon_id=" + rcon_id);
4958
          stmt.executeUpdate();
5149
          stmt.executeUpdate();
4959
          stmt.close();
5150
          stmt.close();
4960
        }
5151
        }
4961
        mConnection.commit();
-
 
4962
        disconnect();
5152
        commit();
4963
      }
5153
      }
4964
      catch( SQLException e )
5154
      catch( SQLException e )
4965
      {
5155
      {
4966
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
5156
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
4967
        {
5157
        {
Line 4972... Line 5162...
4972
        {
5162
        {
4973
          mLogger.fatal("updateCurrentRunLevel show stopper");
5163
          mLogger.fatal("updateCurrentRunLevel show stopper");
4974
          throw new Exception("updateCurrentRunLevel show stopper");
5164
          throw new Exception("updateCurrentRunLevel show stopper");
4975
        }
5165
        }
4976
      }
5166
      }
-
 
5167
      finally
-
 
5168
      {
-
 
5169
        // this block is executed regardless of what happens in the try block
-
 
5170
        // even if an exception is thrown
-
 
5171
        // ensure disconnect
-
 
5172
        disconnect();
-
 
5173
      }
4977
    }
5174
    }
4978
  }
5175
  }
4979
 
5176
 
4980
  public void queryBuildExclusions(Vector<BuildExclusion> buildExclusionCollection, int baseline) throws SQLException, Exception
5177
  public void queryBuildExclusions(Vector<BuildExclusion> buildExclusionCollection, int baseline) throws SQLException, Exception
4981
  {
5178
  {