Subversion Repositories DevTools

Rev

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

Rev 894 Rev 896
Line 130... Line 130...
130
  /**collection of RunLevel objects
130
  /**collection of RunLevel objects
131
   * @attribute
131
   * @attribute
132
   */
132
   */
133
  private Vector<RunLevel> mRunLevelCollection = new Vector<RunLevel>();
133
  private Vector<RunLevel> mRunLevelCollection = new Vector<RunLevel>();
134
  
134
  
-
 
135
  /**set in claimVersion, cleared in discardVersion
-
 
136
   * @attribute
-
 
137
   */
-
 
138
  private String mPlannedPkgId = null;
-
 
139
  
-
 
140
  /**set in claimVersion, cleared in discardVersion
-
 
141
   * @attribute
-
 
142
   */
-
 
143
  private String mPlannedPkgVersion = null;
-
 
144
  
135
  /**in daemon mode
145
  /**in daemon mode
136
   *   select gm.gbe_value from release_manager.release_config rc, release_manager.gbe_machtype gm
146
   *   select gm.gbe_value from release_manager.release_config rc, release_manager.gbe_machtype gm
137
   *   where rc.rtag_id=<baseline> and gm.gbe_id=rc.gbe_id;
147
   *   where rc.rtag_id=<baseline> and gm.gbe_id=rc.gbe_id;
138
   * in escrow mode
148
   * in escrow mode
139
   *   select gm.gbe_value from deployment_manager.boms b, release_manager.release_config rc,
149
   *   select gm.gbe_value from deployment_manager.boms b, release_manager.release_config rc,
Line 3050... Line 3060...
3050
        {
3060
        {
3051
          mLogger.fatal("claimMutex show stopper");
3061
          mLogger.fatal("claimMutex show stopper");
3052
          throw new Exception("claimMutex show stopper");
3062
          throw new Exception("claimMutex show stopper");
3053
        }
3063
        }
3054
      }
3064
      }
-
 
3065
      // about to start the planning process again, discard previous
-
 
3066
      discardVersions();
3055
    }
3067
    }
3056
  }
3068
  }
3057
 
3069
 
3058
  /**sets CURRENT_BUILD_FILES to NULL for the rcon_id
3070
  /**sets CURRENT_BUILD_FILES to NULL for the rcon_id
3059
   * update release_manager.run_level set current_build_files=null where rcon_id=<rcon_id>
3071
   * update release_manager.run_level set current_build_files=null where rcon_id=<rcon_id>
Line 3144... Line 3156...
3144
  /**ensures a run_level_schedule row with a non null indefinite_pause column exists
3156
  /**ensures a run_level_schedule row with a non null indefinite_pause column exists
3145
   * this is aimed at stopping all daemons dead
3157
   * this is aimed at stopping all daemons dead
3146
   * it is raised when handling an unsupported exception case in either the main or slave daemons
3158
   * it is raised when handling an unsupported exception case in either the main or slave daemons
3147
   * typically an SQLException other than a database connection related one
3159
   * typically an SQLException other than a database connection related one
3148
   */
3160
   */
3149
  public void indefinitePause() throws SQLException
3161
  public void indefinitePause()
3150
  {
3162
  {
3151
    mLogger.debug("indefinitePause");
3163
    mLogger.debug("indefinitePause");
3152
    if ( mUseDatabase )
3164
    if ( mUseDatabase )
3153
    {
3165
    {
3154
      try
3166
      try
3155
      {
3167
      {
3156
      connect();
3168
        connect();
3157
      CallableStatement stmt = mConnection.prepareCall( "begin PK_BUILDAPI.SET_INFINITE_PAUSE(); end;" );
3169
        CallableStatement stmt = mConnection.prepareCall( "begin PK_BUILDAPI.SET_INFINITE_PAUSE(); end;" );
3158
      stmt.executeUpdate();
3170
        stmt.executeUpdate();
3159
      stmt.close();
3171
        stmt.close();
3160
      mConnection.commit();
3172
        mConnection.commit();
3161
      disconnect();
3173
        disconnect();
3162
      }
3174
      }
3163
      catch( SQLException e )
3175
      catch( SQLException e )
3164
      {
3176
      {
3165
        // do not throw Exception
3177
        // do not throw Exception
3166
        // this is part of Exception handling
3178
        // this is part of Exception handling
Line 3171... Line 3183...
3171
        mLogger.fatal( "indefinitePause caught Exception " + e.getMessage() );
3183
        mLogger.fatal( "indefinitePause caught Exception " + e.getMessage() );
3172
      }
3184
      }
3173
    }
3185
    }
3174
  }
3186
  }
3175
 
3187
 
-
 
3188
  /**ensures a run_level_schedule row with a non null indefinite_pause column does not exist
-
 
3189
   * this is aimed at resuming all daemons
-
 
3190
   */
-
 
3191
  private void resume() throws SQLException, Exception
-
 
3192
  {
-
 
3193
    mLogger.debug("resume");
-
 
3194
    if ( mUseDatabase )
-
 
3195
    {
-
 
3196
      try
-
 
3197
      {
-
 
3198
        CallableStatement stmt = mConnection.prepareCall( "begin PK_BUILDAPI.SET_RESUME(); end;" );
-
 
3199
        stmt.executeUpdate();
-
 
3200
        stmt.close();
-
 
3201
        mConnection.commit();
-
 
3202
      }
-
 
3203
      catch ( SQLException e )
-
 
3204
      {
-
 
3205
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
-
 
3206
        {
-
 
3207
          mLogger.error("resume database access error only");
-
 
3208
          throw new SQLException();
-
 
3209
        }
-
 
3210
        else
-
 
3211
        {
-
 
3212
          mLogger.fatal("resume show stopper");
-
 
3213
          throw new Exception("resume show stopper");
-
 
3214
        }
-
 
3215
      }
-
 
3216
    }
-
 
3217
  }
-
 
3218
 
3176
  /**only used in daemon mode to determine version existence in the database
3219
  /**only used in daemon mode to determine version existence in the database
3177
   *  1 select pkg_id from release_manager.package_versions where pkg_id=<pkg_id> and pkg_version=<pkg_version>;
3220
   *  1 select pkg_id from release_manager.package_versions where pkg_id=<pkg_id> and pkg_version=<pkg_version>;
3178
   *  2 select pkg_id from release_manager.planned_versions where pkg_id=<pkg_id> and pkg_version=<pkg_version>;
3221
   *  2 select pkg_id from release_manager.planned_versions where pkg_id=<pkg_id> and pkg_version=<pkg_version>;
3179
   * returns true if either resultset contains one record to indicate it already exists
3222
   * returns true if either resultset contains one record to indicate it already exists
3180
   */
3223
   */
Line 3274... Line 3317...
3274
    {
3317
    {
3275
      try
3318
      try
3276
      {
3319
      {
3277
        if (isRtagIdConfigured( rtag_id ))
3320
        if (isRtagIdConfigured( rtag_id ))
3278
        {
3321
        {
3279
          CallableStatement stmt3 = mConnection.prepareCall("insert into release_manager.planned_versions (pkg_id, pkg_version) values (" + pkg_id + ", '" + pkg_version + "')");
3322
          CallableStatement stmt3 = mConnection.prepareCall("insert into release_manager.planned_versions (pkg_id, pkg_version, planned_time) values (" + pkg_id + ", '" + pkg_version + "', sysdate)");
3280
          stmt3.executeUpdate();
3323
          stmt3.executeUpdate();
3281
          stmt3.close();
3324
          stmt3.close();
3282
          CallableStatement stmt4 = mConnection.prepareCall(
3325
          CallableStatement stmt4 = mConnection.prepareCall(
3283
          "update " +
3326
          "update " +
3284
          "(" +
3327
          "(" +
Line 3287... Line 3330...
3287
          ")" +
3330
          ")" +
3288
          "set current_pkg_id_being_built=" + pkg_id);
3331
          "set current_pkg_id_being_built=" + pkg_id);
3289
          stmt4.executeUpdate();
3332
          stmt4.executeUpdate();
3290
          stmt4.close();
3333
          stmt4.close();
3291
          mConnection.commit();
3334
          mConnection.commit();
-
 
3335
          mPlannedPkgId = new String();
-
 
3336
          mPlannedPkgId += pkg_id;
-
 
3337
          mPlannedPkgVersion = new String( pkg_version );
3292
        }
3338
        }
3293
      }
3339
      }
3294
      catch ( SQLException e )
3340
      catch ( SQLException e )
3295
      {
3341
      {
3296
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3342
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
Line 3306... Line 3352...
3306
      }
3352
      }
3307
    }
3353
    }
3308
  }
3354
  }
3309
 
3355
 
3310
  /**only used in daemon mode
3356
  /**only used in daemon mode
-
 
3357
   * delete from release_manager.planned_versions where pkg_id=<pkg_id> and pkg_version=<pkg_version>;
-
 
3358
   */
-
 
3359
  public void discardVersion() throws SQLException, Exception
-
 
3360
  {
-
 
3361
    mLogger.debug("discardVersion");
-
 
3362
    if ( mPlannedPkgId != null && mPlannedPkgVersion != null )
-
 
3363
    {
-
 
3364
      try
-
 
3365
      {
-
 
3366
        CallableStatement stmt = mConnection.prepareCall("delete from release_manager.planned_versions where pkg_id=" + mPlannedPkgId + " and pkg_version='" + mPlannedPkgVersion + "'");
-
 
3367
        stmt.executeUpdate();
-
 
3368
        stmt.close();
-
 
3369
        mConnection.commit();
-
 
3370
        mPlannedPkgId = null;
-
 
3371
        mPlannedPkgVersion = null;
-
 
3372
      }
-
 
3373
      catch ( SQLException e )
-
 
3374
      {
-
 
3375
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
-
 
3376
        {
-
 
3377
          mLogger.error("discardVersion database access error only");
-
 
3378
          throw new SQLException();
-
 
3379
        }
-
 
3380
        else
-
 
3381
        {
-
 
3382
          mLogger.fatal("discardVersion show stopper");
-
 
3383
          throw new Exception("discardVersion show stopper");
-
 
3384
        }
-
 
3385
      }
-
 
3386
    }
-
 
3387
  }
-
 
3388
 
-
 
3389
  /**only used in daemon mode
-
 
3390
   * delete planned versions over 24 hours old (rounded to the nearest hour that is)
-
 
3391
   * delete from release_manager.planned_versions where planned_time < trunc(sysdate, 'hh') - 1");
-
 
3392
   */
-
 
3393
  private void discardVersions() throws SQLException, Exception
-
 
3394
  {
-
 
3395
    mLogger.debug("discardVersions");
-
 
3396
    try
-
 
3397
    {
-
 
3398
      // housekeep whilst the daemon has the mutex
-
 
3399
      // trunc(sysdate, 'hh') returns the time now rounded to the nearest hour
-
 
3400
      // 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
-
 
3402
      CallableStatement stmt = mConnection.prepareCall("delete from release_manager.planned_versions where planned_time < trunc(sysdate, 'hh') - 1");
-
 
3403
      stmt.executeUpdate();
-
 
3404
      stmt.close();
-
 
3405
      mConnection.commit();
-
 
3406
    }
-
 
3407
    catch ( SQLException e )
-
 
3408
    {
-
 
3409
      if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
-
 
3410
      {
-
 
3411
        mLogger.error("discardVersions database access error only");
-
 
3412
        throw new SQLException();
-
 
3413
      }
-
 
3414
      else
-
 
3415
      {
-
 
3416
        mLogger.fatal("discardVersions show stopper");
-
 
3417
        throw new Exception("discardVersions show stopper");
-
 
3418
      }
-
 
3419
    }
-
 
3420
  }
-
 
3421
 
-
 
3422
  /**only used in daemon mode
3311
   *  update
3423
   *  update
3312
   *  (
3424
   *  (
3313
   *  select current_pkg_id_being_built from release_manager.run_level
3425
   *  select current_pkg_id_being_built from release_manager.run_level
3314
   *  where rcon_id=<rcon_id>
3426
   *  where rcon_id=<rcon_id>
3315
   *  )
3427
   *  )
Line 3467... Line 3579...
3467
    if ( mUseDatabase )
3579
    if ( mUseDatabase )
3468
    {
3580
    {
3469
      try
3581
      try
3470
      {
3582
      {
3471
        connect();
3583
        connect();
3472
        CallableStatement stmt = mConnection.prepareCall( "begin ? := PK_RMAPI.EXCLUDE_INDIRECT_FROM_BUILD(?,?,?,?,?,?,?); end;" );
-
 
3473
        stmt.registerOutParameter( 1, Types.INTEGER);
-
 
3474
        stmt.setString( 2, packageVersionId );
-
 
3475
        stmt.setString( 3, packageVersion );
-
 
3476
        stmt.setString( 4, rtagId );
3584
        boolean exist = false;
3477
        stmt.setString( 5, "buildadm" );
-
 
3478
        stmt.setString( 6, rootPvId);
3585
        
3479
        stmt.setString( 7, rootCause);
3586
        // do not exclude a package already excluded ie let the first build failure count
3480
        stmt.setString( 8, rootFile);
3587
        CallableStatement stmt = mConnection.prepareCall("select pv_id from release_manager.do_not_ripple where pv_id=" + packageVersionId + "and rtag_id=" + rtagId);
3481
        stmt.executeUpdate();
-
 
3482
        int result = stmt.getInt( 1 );
3588
        ResultSet rset = stmt.executeQuery();
3483
      
3589
        
3484
        if ( result != 0 )
3590
        while( rset.next() )
3485
        {
3591
        {
3486
          // flag build failure
3592
          exist = true;
3487
          mLogger.fatal( "excludeFromBuild show stopper PK_RMAPI.EXCLUDE_INDIRECT_FROM_BUILD failed, returned " + result );
3593
          break;
3488
          throw new Exception("excludeFromBuild show stopper PK_RMAPI.EXCLUDE_INDIRECT_FROM_BUILD failed, returned " + result);
-
 
3489
        }
3594
        }
-
 
3595
 
-
 
3596
        rset.close();
3490
        stmt.close();
3597
        stmt.close();
-
 
3598
        
-
 
3599
        if ( !exist )
-
 
3600
        {
-
 
3601
          stmt = mConnection.prepareCall( "begin ? := PK_RMAPI.EXCLUDE_INDIRECT_FROM_BUILD(?,?,?,?,?,?,?); end;" );
-
 
3602
          stmt.registerOutParameter( 1, Types.INTEGER);
-
 
3603
          stmt.setString( 2, packageVersionId );
-
 
3604
          stmt.setString( 3, packageVersion );
-
 
3605
          stmt.setString( 4, rtagId );
-
 
3606
          stmt.setString( 5, "buildadm" );
-
 
3607
          stmt.setString( 6, rootPvId);
-
 
3608
          stmt.setString( 7, rootCause);
-
 
3609
          stmt.setString( 8, rootFile);
-
 
3610
          stmt.executeUpdate();
-
 
3611
          int result = stmt.getInt( 1 );
-
 
3612
        
-
 
3613
          if ( result != 0 )
-
 
3614
          {
-
 
3615
            // flag build failure
-
 
3616
            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);
-
 
3618
          }
-
 
3619
          stmt.close();
3491
        mConnection.commit();
3620
          mConnection.commit();
-
 
3621
        }
3492
        disconnect();
3622
        disconnect();
3493
      }
3623
      }
3494
      catch( SQLException e )
3624
      catch( SQLException e )
3495
      {
3625
      {
3496
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
3626
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
Line 3554... Line 3684...
3554
    /**daemon_mode column value
3684
    /**daemon_mode column value
3555
     * @attribute
3685
     * @attribute
3556
     */
3686
     */
3557
    private char mDaemon_mode;
3687
    private char mDaemon_mode;
3558
 
3688
 
3559
    /**gbebuildfilter column value
-
 
3560
     * @attribute
-
 
3561
     */
-
 
3562
    private String mGbebuildfilter;
-
 
3563
 
-
 
3564
    /**constructor
3689
    /**constructor
3565
     */
3690
     */
3566
    ReleaseConfig(int rtag_id, int rcon_id, char daemon_mode, 
3691
    ReleaseConfig(int rtag_id, int rcon_id, char daemon_mode)
3567
                  String gbebuildfilter)
-
 
3568
    {
3692
    {
3569
      mLogger.debug("ReleaseConfig rtag_id " + rtag_id + " rcon_id " + rcon_id + " daemon_mode " + daemon_mode + " gbebuildfilter " + gbebuildfilter );
3693
      mLogger.debug("ReleaseConfig rtag_id " + rtag_id + " rcon_id " + rcon_id + " daemon_mode " + daemon_mode );
3570
      mRtag_id = rtag_id;
3694
      mRtag_id = rtag_id;
3571
      mRcon_id = rcon_id;
3695
      mRcon_id = rcon_id;
3572
      mDaemon_mode = daemon_mode;
3696
      mDaemon_mode = daemon_mode;
3573
      mGbebuildfilter = gbebuildfilter;
-
 
3574
    }
3697
    }
3575
 
3698
 
3576
    /**accessor method
3699
    /**accessor method
3577
     */
3700
     */
3578
    int get_rtag_id()
3701
    int get_rtag_id()
Line 3597... Line 3720...
3597
    {
3720
    {
3598
      mLogger.debug("get_daemon_mode");
3721
      mLogger.debug("get_daemon_mode");
3599
      mLogger.info("get_daemon_mode returned " + mDaemon_mode);
3722
      mLogger.info("get_daemon_mode returned " + mDaemon_mode);
3600
      return mDaemon_mode;
3723
      return mDaemon_mode;
3601
    }
3724
    }
3602
 
-
 
3603
    /**accessor method
-
 
3604
     */
-
 
3605
    String get_gbebuildfilter()
-
 
3606
    {
-
 
3607
      mLogger.debug("get_gbebuildfilter");
-
 
3608
      mLogger.info("get_gbebuildfilter returned " + mGbebuildfilter);
-
 
3609
      return mGbebuildfilter;
-
 
3610
    }
-
 
3611
  }
3725
  }
3612
 
3726
 
3613
  /**Representation of a row in the RUN_LEVEL table
3727
  /**Representation of a row in the RUN_LEVEL table
3614
   */
3728
   */
3615
  private class RunLevel
3729
  private class RunLevel
Line 3824... Line 3938...
3824
 
3938
 
3825
  /**returns true if the mReleaseConfigCollection is not empty and returns the rcon_id, rtag_id, daemon_mode and gbebuildfilter of the first element
3939
  /**returns true if the mReleaseConfigCollection is not empty and returns the rcon_id, rtag_id, daemon_mode and gbebuildfilter of the first element
3826
   */
3940
   */
3827
  public boolean getFirstReleaseConfig(MutableInt rtag_id, 
3941
  public boolean getFirstReleaseConfig(MutableInt rtag_id, 
3828
                                       MutableInt rcon_id, 
3942
                                       MutableInt rcon_id, 
3829
                                       MutableChar daemon_mode, 
3943
                                       MutableChar daemon_mode)
3830
                                       MutableString gbebuildfilter)
-
 
3831
  {
3944
  {
3832
    mLogger.debug("getFirstReleaseConfig 2");
3945
    mLogger.debug("getFirstReleaseConfig 2");
3833
    boolean retVal = true;
3946
    boolean retVal = true;
3834
    
3947
    
3835
    try
3948
    try
Line 3837... Line 3950...
3837
      mReleaseConfigIndex = 0;
3950
      mReleaseConfigIndex = 0;
3838
      ReleaseConfig rc = mReleaseConfigCollection.get( mReleaseConfigIndex );
3951
      ReleaseConfig rc = mReleaseConfigCollection.get( mReleaseConfigIndex );
3839
      rtag_id.value = rc.get_rtag_id();
3952
      rtag_id.value = rc.get_rtag_id();
3840
      rcon_id.value = rc.get_rcon_id();
3953
      rcon_id.value = rc.get_rcon_id();
3841
      daemon_mode.value = rc.get_daemon_mode();
3954
      daemon_mode.value = rc.get_daemon_mode();
3842
      gbebuildfilter.value = rc.get_gbebuildfilter();
-
 
3843
    }
3955
    }
3844
    catch( ArrayIndexOutOfBoundsException e )
3956
    catch( ArrayIndexOutOfBoundsException e )
3845
    {
3957
    {
3846
      retVal = false;
3958
      retVal = false;
3847
    }
3959
    }
Line 3898... Line 4010...
3898
 
4010
 
3899
  /**returns true if the mReleaseConfigCollection contains a next element and returns the rcon_id, rtag_id, daemon_mode and gbebuildfilter of the next element
4011
  /**returns true if the mReleaseConfigCollection contains a next element and returns the rcon_id, rtag_id, daemon_mode and gbebuildfilter of the next element
3900
   */
4012
   */
3901
  public boolean getNextReleaseConfig(MutableInt rtag_id, 
4013
  public boolean getNextReleaseConfig(MutableInt rtag_id, 
3902
                                      MutableInt rcon_id, 
4014
                                      MutableInt rcon_id, 
3903
                                      MutableChar daemon_mode, 
4015
                                      MutableChar daemon_mode)
3904
                                      MutableString gbebuildfilter)
-
 
3905
  {
4016
  {
3906
    mLogger.debug("getNextReleaseConfig 2");
4017
    mLogger.debug("getNextReleaseConfig 2");
3907
    boolean retVal = true;
4018
    boolean retVal = true;
3908
    
4019
    
3909
    try
4020
    try
Line 3911... Line 4022...
3911
      mReleaseConfigIndex++;
4022
      mReleaseConfigIndex++;
3912
      ReleaseConfig rc = mReleaseConfigCollection.get( mReleaseConfigIndex );
4023
      ReleaseConfig rc = mReleaseConfigCollection.get( mReleaseConfigIndex );
3913
      rtag_id.value = rc.get_rtag_id();
4024
      rtag_id.value = rc.get_rtag_id();
3914
      rcon_id.value = rc.get_rcon_id();
4025
      rcon_id.value = rc.get_rcon_id();
3915
      daemon_mode.value = rc.get_daemon_mode();
4026
      daemon_mode.value = rc.get_daemon_mode();
3916
      gbebuildfilter.value = rc.get_gbebuildfilter();
-
 
3917
    }
4027
    }
3918
    catch( ArrayIndexOutOfBoundsException e )
4028
    catch( ArrayIndexOutOfBoundsException e )
3919
    {
4029
    {
3920
      retVal = false;
4030
      retVal = false;
3921
    }
4031
    }
Line 4012... Line 4122...
4012
   
4122
   
4013
    mLogger.info("queryDirectedRunLevel returning " + retVal);
4123
    mLogger.info("queryDirectedRunLevel returning " + retVal);
4014
    return retVal;
4124
    return retVal;
4015
  }
4125
  }
4016
 
4126
 
4017
  /**queries the RELEASE_CONFIG table using the rcon_id primary key, rtag_id, daemon_hostname, daemon_mode, gbebuildfilter
4127
  /**queries the RELEASE_CONFIG table using the rcon_id primary key, rtag_id, daemon_hostname, daemon_mode
4018
   * return true if the query contains a result set containing one row
4128
   * return true if the query contains a result set containing one row
4019
   * (indicating the rcon_id is still configured and its configuration is unchanged)
4129
   * (indicating the rcon_id is still configured and its configuration is unchanged, aside from the gbe_buildfilter)
-
 
4130
   * the gbe_buildfilter is queried prior to usage
4020
   * refer to sequence diagram allowed to proceed
4131
   * refer to sequence diagram allowed to proceed
4021
   */
4132
   */
4022
  public boolean queryReleaseConfig(final int rtag_id, final int rcon_id, 
4133
  public boolean queryReleaseConfig(final int rtag_id, final int rcon_id, 
4023
                                    final String daemon_hostname, 
4134
                                    final String daemon_hostname, 
4024
                                    final char daemon_mode, 
-
 
4025
                                    final String gbebuildfilter) throws SQLException, Exception
4135
                                    final char daemon_mode) throws SQLException, Exception
4026
  {
4136
  {
4027
    mLogger.debug("queryReleaseConfig 1");
4137
    mLogger.debug("queryReleaseConfig 1");
4028
    boolean retVal = false;
4138
    boolean retVal = false;
4029
    
4139
    
4030
    if ( !mUseDatabase )
4140
    if ( !mUseDatabase )
Line 4046... Line 4156...
4046
        int rsetSize = 0;
4156
        int rsetSize = 0;
4047
        
4157
        
4048
        while( rset.next() )
4158
        while( rset.next() )
4049
        {
4159
        {
4050
          rsetSize++;
4160
          rsetSize++;
4051
          String gbe_buildfilter = rset.getString("gbe_buildfilter");
-
 
4052
          
-
 
4053
          if ( gbe_buildfilter == null )
-
 
4054
          {
-
 
4055
            mLogger.info("queryReleaseConfig 1 gbe_buildfilter == null");
-
 
4056
            if ( gbebuildfilter.length() == 0 )
-
 
4057
            {
-
 
4058
              retVal = true;
4161
          retVal = true;
4059
            }
-
 
4060
          }
-
 
4061
          else
-
 
4062
          {
-
 
4063
            if ( gbebuildfilter.compareTo( gbe_buildfilter ) == 0 )
-
 
4064
            {
-
 
4065
              retVal = true;
-
 
4066
            }
-
 
4067
          }
-
 
4068
        }
4162
        }
4069
        
4163
        
4070
        rset.close();
4164
        rset.close();
4071
        stmt.close();
4165
        stmt.close();
4072
 
4166
 
Line 4094... Line 4188...
4094
    
4188
    
4095
    mLogger.info("queryReleaseConfig 1 returning " + retVal);
4189
    mLogger.info("queryReleaseConfig 1 returning " + retVal);
4096
    return retVal;
4190
    return retVal;
4097
  }
4191
  }
4098
 
4192
 
-
 
4193
  /**queries the RELEASE_CONFIG table using the rcon_id primary key for the gbebuildfilter
-
 
4194
   */
-
 
4195
  public void queryBuildFilter(final int rcon_id, 
-
 
4196
                               MutableString gbebuildfilter) throws SQLException, Exception
-
 
4197
  {
-
 
4198
    mLogger.debug("queryBuildFilter");
-
 
4199
    
-
 
4200
    if ( !mUseDatabase )
-
 
4201
    {
-
 
4202
      mLogger.info("queryBuildFilter !mUseDatabase");
-
 
4203
    }
-
 
4204
    else
-
 
4205
    {
-
 
4206
      try
-
 
4207
      {
-
 
4208
        String sql = new String("select gbe_buildfilter from release_manager.release_config where rcon_id=" + rcon_id );
-
 
4209
        CallableStatement stmt = mConnection.prepareCall( sql );
-
 
4210
        ResultSet rset = stmt.executeQuery();
-
 
4211
        int rsetSize = 0;
-
 
4212
        
-
 
4213
        while( rset.next() )
-
 
4214
        {
-
 
4215
          rsetSize++;
-
 
4216
          gbebuildfilter.value = rset.getString("gbe_buildfilter");
-
 
4217
        }
-
 
4218
        
-
 
4219
        rset.close();
-
 
4220
        stmt.close();
-
 
4221
 
-
 
4222
        if ( rsetSize > 1 )
-
 
4223
        {
-
 
4224
          mLogger.fatal("queryBuildFilter rsetSize > 1");
-
 
4225
          // show stopper
-
 
4226
          throw new Exception("queryBuildFilter rsetSize > 1");
-
 
4227
        }
-
 
4228
      }
-
 
4229
      catch ( SQLException e )
-
 
4230
      {
-
 
4231
        if ( mConnection == null || ( mConnection != null && !mConnection.isValid(10) ) )
-
 
4232
        {
-
 
4233
          mLogger.error("queryBuildFilter database access error only");
-
 
4234
          throw new SQLException();
-
 
4235
        }
-
 
4236
        else
-
 
4237
        {
-
 
4238
          mLogger.fatal("queryBuildFilter show stopper");
-
 
4239
          throw new Exception("queryBuildFilter show stopper");
-
 
4240
        }
-
 
4241
      }
-
 
4242
    }
-
 
4243
  }
-
 
4244
 
4099
  /**removes all elements from the mReleaseConfigCollection
4245
  /**removes all elements from the mReleaseConfigCollection
4100
   * handles database connection and disconnection
4246
   * handles database connection and disconnection
4101
   * queries the RELEASE_CONFIG table using the rtag_id
4247
   * queries the RELEASE_CONFIG table using the rtag_id
4102
   * populates the mReleaseConfigCollection with the query result set
4248
   * populates the mReleaseConfigCollection with the query result set
4103
   * partially implements the sequence diagrams coordinate slave threads generate build files
4249
   * partially implements the sequence diagrams coordinate slave threads generate build files
Line 4108... Line 4254...
4108
    mReleaseConfigCollection.removeAllElements();
4254
    mReleaseConfigCollection.removeAllElements();
4109
    
4255
    
4110
    if ( !mUseDatabase )
4256
    if ( !mUseDatabase )
4111
    {
4257
    {
4112
      mLogger.info("queryReleaseConfig 2 !mUseDatabase");
4258
      mLogger.info("queryReleaseConfig 2 !mUseDatabase");
4113
      ReleaseConfig releaseConfig = new ReleaseConfig(1,1,'M',"unittestbuildfilter");
4259
      ReleaseConfig releaseConfig = new ReleaseConfig(1,1,'M');
4114
      mReleaseConfigCollection.add(releaseConfig);
4260
      mReleaseConfigCollection.add(releaseConfig);
4115
      releaseConfig = new ReleaseConfig(1,2,'S',"anotherunittestbuildfilter");
4261
      releaseConfig = new ReleaseConfig(1,2,'S');
4116
      mReleaseConfigCollection.add(releaseConfig);
4262
      mReleaseConfigCollection.add(releaseConfig);
4117
    }
4263
    }
4118
    else
4264
    else
4119
    {
4265
    {
4120
      try
4266
      try
4121
      {
4267
      {
4122
        connect();
4268
        connect();
4123
        
4269
        
4124
        CallableStatement stmt = mConnection.prepareCall("select rcon_id, daemon_mode, gbe_buildfilter from release_manager.release_config where rtag_id=" + rtag_id );
4270
        CallableStatement stmt = mConnection.prepareCall("select rcon_id, daemon_mode from release_manager.release_config where rtag_id=" + rtag_id );
4125
        ResultSet rset = stmt.executeQuery();
4271
        ResultSet rset = stmt.executeQuery();
4126
        
4272
        
4127
        while( rset.next() )
4273
        while( rset.next() )
4128
        {
4274
        {
4129
          int rcon_id = rset.getInt("rcon_id");
4275
          int rcon_id = rset.getInt("rcon_id");
Line 4146... Line 4292...
4146
            {
4292
            {
4147
              dm = 'M';
4293
              dm = 'M';
4148
            }
4294
            }
4149
          }
4295
          }
4150
          
4296
          
4151
          String gbe_buildfilter = rset.getString("gbe_buildfilter");
-
 
4152
          
-
 
4153
          if ( gbe_buildfilter == null )
-
 
4154
          {
-
 
4155
            gbe_buildfilter = new String("");
-
 
4156
          }
-
 
4157
          
-
 
4158
          ReleaseConfig releaseConfig = new ReleaseConfig( rtag_id, rcon_id, dm, gbe_buildfilter );
4297
          ReleaseConfig releaseConfig = new ReleaseConfig( rtag_id, rcon_id, dm );
4159
          mReleaseConfigCollection.add(releaseConfig);
4298
          mReleaseConfigCollection.add(releaseConfig);
4160
        }
4299
        }
4161
        
4300
        
4162
        
4301
        
4163
        rset.close();
4302
        rset.close();
Line 4193... Line 4332...
4193
    
4332
    
4194
    if ( mConnectionString.compareTo("unit test spawn thread") == 0)
4333
    if ( mConnectionString.compareTo("unit test spawn thread") == 0)
4195
    {
4334
    {
4196
      mLogger.info("queryReleaseConfig 3 unit test spawn thread");
4335
      mLogger.info("queryReleaseConfig 3 unit test spawn thread");
4197
      // specifying a gbebuildfilter of unit test is designed to invoke a benign thread for unit test purposes
4336
      // specifying a gbebuildfilter of unit test is designed to invoke a benign thread for unit test purposes
4198
      ReleaseConfig releaseConfig = new ReleaseConfig(1,1,'M',"unit test spawn thread");
4337
      ReleaseConfig releaseConfig = new ReleaseConfig(1,1,'M');
4199
      mReleaseConfigCollection.add(releaseConfig);
4338
      mReleaseConfigCollection.add(releaseConfig);
4200
      releaseConfig = new ReleaseConfig(2,2,'S',"unit test spawn thread");
4339
      releaseConfig = new ReleaseConfig(2,2,'S');
4201
      mReleaseConfigCollection.add(releaseConfig);
4340
      mReleaseConfigCollection.add(releaseConfig);
4202
    }
4341
    }
4203
    else
4342
    else
4204
    {
4343
    {
4205
      try
4344
      try
4206
      {
4345
      {
4207
        connect();
4346
        connect();
4208
        CallableStatement stmt = mConnection.prepareCall("select rc.rtag_id, rc.rcon_id, rc.daemon_mode, rc.gbe_buildfilter from release_manager.release_config rc, release_manager.release_tags rt where rc.daemon_hostname='" + hostname + "' and rt.rtag_id=rc.rtag_id and (rt.official = 'N' or rt.official='R' or rt.official='C')" );
4347
        CallableStatement stmt = mConnection.prepareCall("select rc.rtag_id, rc.rcon_id, rc.daemon_mode from release_manager.release_config rc, release_manager.release_tags rt where rc.daemon_hostname='" + hostname + "' and rt.rtag_id=rc.rtag_id and (rt.official = 'N' or rt.official='R' or rt.official='C')" );
4209
        ResultSet rset = stmt.executeQuery();
4348
        ResultSet rset = stmt.executeQuery();
4210
        
4349
        
4211
        while( rset.next() )
4350
        while( rset.next() )
4212
        {
4351
        {
4213
          int rtag_id = rset.getInt("rtag_id");
4352
          int rtag_id = rset.getInt("rtag_id");
Line 4239... Line 4378...
4239
            {
4378
            {
4240
              dm = 'M';
4379
              dm = 'M';
4241
            }
4380
            }
4242
          }
4381
          }
4243
          
4382
          
4244
          String gbe_buildfilter = rset.getString("gbe_buildfilter");
-
 
4245
          
-
 
4246
          if ( gbe_buildfilter == null )
-
 
4247
          {
-
 
4248
            gbe_buildfilter = new String("");
-
 
4249
          }
-
 
4250
          
-
 
4251
          ReleaseConfig releaseConfig = new ReleaseConfig( rtag_id, rcon_id, dm, gbe_buildfilter );
4383
          ReleaseConfig releaseConfig = new ReleaseConfig( rtag_id, rcon_id, dm );
4252
          mReleaseConfigCollection.add(releaseConfig);
4384
          mReleaseConfigCollection.add(releaseConfig);
4253
        }
4385
        }
4254
        
4386
        
4255
        rset.close();
4387
        rset.close();
4256
        stmt.close();
4388
        stmt.close();
Line 4272... Line 4404...
4272
    }
4404
    }
4273
  }
4405
  }
4274
 
4406
 
4275
  /**queries the RUN_LEVEL table using the rcon_id primary key
4407
  /**queries the RUN_LEVEL table using the rcon_id primary key
4276
   * handles database connection and disconnection
4408
   * handles database connection and disconnection
4277
   * polls indefinitely until CURRENT_BUILD_FILES column is non NULL
-
 
4278
   * returns the current_build_files
4409
   * returns the current_build_files
4279
   * implements the sequence diagram consume build files
4410
   * implements the sequence diagram consume build files
4280
   */
4411
   */
4281
  public void queryRunLevel(int rcon_id, MutableString currentBuildFiles) throws SQLException, Exception
4412
  public void queryRunLevel(int rcon_id, MutableString currentBuildFiles) throws SQLException, Exception
4282
  {
4413
  {
Line 4505... Line 4636...
4505
      }
4636
      }
4506
    }
4637
    }
4507
  }
4638
  }
4508
 
4639
 
4509
  /**queries the RUN_LEVEL_SCHEDULE table
4640
  /**queries the RUN_LEVEL_SCHEDULE table
-
 
4641
   * when recover is true, checks for archive existence and runs resume when both archives exist
-
 
4642
   * this should delete rows with a non NULL indefinite pause
4510
   * returns false if a row in the query result set indicates build service downtime is scheduled
4643
   * returns false if a row in the query result set indicates build service downtime is scheduled
4511
   * returns false if a row in the query result set has a non NULL indefinite_pause
4644
   * returns false if a row in the query result set has a non NULL indefinite_pause
4512
   * refer to the sequence diagram allowed to proceed
4645
   * refer to the sequence diagram allowed to proceed
4513
   */
4646
   */
4514
  public boolean queryRunLevelSchedule(Date resumeTime) throws SQLException, Exception
4647
  public boolean queryRunLevelSchedule(Date resumeTime, boolean recover) throws SQLException, Exception
4515
  {
4648
  {
4516
    mLogger.debug("queryRunLevelSchedule");
4649
    mLogger.debug("queryRunLevelSchedule");
4517
    boolean retVal = true;
4650
    boolean retVal = true;
4518
    
4651
    
4519
    if ( !mUseDatabase )
4652
    if ( !mUseDatabase )
Line 4529... Line 4662...
4529
    }
4662
    }
4530
    else
4663
    else
4531
    {
4664
    {
4532
      try
4665
      try
4533
      {
4666
      {
-
 
4667
        if ( recover )
-
 
4668
        {
-
 
4669
          if ( Package.recover() )
-
 
4670
          {
-
 
4671
            // dpkg and deploy archives exist
-
 
4672
            // clear the indefinite pause condition
-
 
4673
            resume();
-
 
4674
          }
-
 
4675
        }
4534
        CallableStatement stmt = mConnection.prepareCall("select scheduled_pause, scheduled_resume, repeat, indefinite_pause from release_manager.run_level_schedule");
4676
        CallableStatement stmt = mConnection.prepareCall("select scheduled_pause, scheduled_resume, repeat, indefinite_pause from release_manager.run_level_schedule");
4535
        ResultSet rset = stmt.executeQuery();
4677
        ResultSet rset = stmt.executeQuery();
4536
        Date now = new Date();
4678
        Date now = new Date();
4537
 
4679
 
4538
 
4680
 
Line 4649... Line 4791...
4649
 
4791
 
4650
          //
4792
          //
4651
          //  Look for indefinite_pause style of entry
4793
          //  Look for indefinite_pause style of entry
4652
          //  Note: due to an implemenation error there may be many
4794
          //  Note: due to an implemenation error there may be many
4653
          //        rows that match. We only need one. The scan will
4795
          //        rows that match. We only need one. The scan will
4654
          //        be termineted if we find any
4796
          //        be terminated if we find any
4655
          //  
4797
          //  
4656
          //
4798
          //
4657
          String ip = rset.getString("indefinite_pause");
4799
          String ip = rset.getString("indefinite_pause");
4658
          if ( ip != null )
4800
          if ( ip != null )
4659
          {
4801
          {