Subversion Repositories DevTools

Rev

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

Rev 7180 Rev 7186
Line 399... Line 399...
399
     */
399
     */
400
    private RmConnection connect( RmConnection rmc ) throws SQLException
400
    private RmConnection connect( RmConnection rmc ) throws SQLException
401
    {
401
    {
402
        mLogger.debug("connect");
402
        mLogger.debug("connect");
403
        
403
        
404
        //  Reset the internal package caching mechanism
-
 
405
        findPackageResetCache();
-
 
406
 
-
 
407
        try
404
        try
408
        {
405
        {
409
            if ( rmc.mSession.isHeldByCurrentThread() )
406
            if ( rmc.mSession.isHeldByCurrentThread() )
410
            {
407
            {
411
                // by design a thread must NOT connect multiple times
408
                // by design a thread must NOT connect multiple times
Line 2503... Line 2500...
2503
     * @param   baseline            - RtagId of the release being processed, BomId of an Escrow being processed
2500
     * @param   baseline            - RtagId of the release being processed, BomId of an Escrow being processed
2504
     *  
2501
     *  
2505
     * Overridden in ReleaseManagerUtf
2502
     * Overridden in ReleaseManagerUtf
2506
     *  
2503
     *  
2507
     */
2504
     */
2508
    protected void queryPackageVersions(RippleEngine rippleEngine, ArrayList<Package> packageCollection, int baseline) throws SQLException, Exception
2505
    protected void queryPackageVersions(RippleEngine rippleEngine, PackageCollection packageCollection, int baseline) throws SQLException, Exception
2509
    {
2506
    {
2510
        Phase phase = new Phase("rmData");
2507
        Phase phase = new Phase("rmData");
2511
        mLogger.debug("queryPackageVersions {}", mDaemon);
2508
        mLogger.debug("queryPackageVersions {}", mDaemon);
2512
        
2509
        
2513
        try
2510
        try
Line 2588... Line 2585...
2588
                    //  If this package is to be replaced by a planned package then
2585
                    //  If this package is to be replaced by a planned package then
2589
                    //  insert some of the current packages attributes
2586
                    //  insert some of the current packages attributes
2590
                    //  Otherwise, add the the package to the package collection
2587
                    //  Otherwise, add the the package to the package collection
2591
                    //  TODO - Not sure this code is in use anymore
2588
                    //  TODO - Not sure this code is in use anymore
2592
 
2589
 
2593
                    Package plannedPackage = findPackage(p.mAlias, packageCollection);
2590
                    Package plannedPackage = packageCollection.contains(p.mAlias);
2594
                    if ( plannedPackage == NULL_PACKAGE )
2591
                    if ( plannedPackage == null )
2595
                    {
2592
                    {
2596
                        mLogger.debug("queryPackageVersions rset8 no planned package {}", pv_id);
2593
                        mLogger.debug("queryPackageVersions rset8 no planned package {}", pv_id);
2597
                        packageCollection.add(p);
2594
                        packageCollection.add(p);
2598
                    }
2595
                    }
2599
                    else
2596
                    else
Line 2640... Line 2637...
2640
                    int pv_id = rset9.mustGetKeyInt("pv_id");
2637
                    int pv_id = rset9.mustGetKeyInt("pv_id");
2641
                    int dpv_id = rset9.mustGetInt("dpv_id");
2638
                    int dpv_id = rset9.mustGetInt("dpv_id");
2642
                    String pkg_name = rset9.mustGetString("pkg_name");
2639
                    String pkg_name = rset9.mustGetString("pkg_name");
2643
                    String v_ext = rset9.getString("v_ext","");
2640
                    String v_ext = rset9.getString("v_ext","");
2644
 
2641
 
2645
                    Package p = findPackage(pv_id, packageCollection);
2642
                    Package p = packageCollection.contains(pv_id);
2646
                    if ( p != NULL_PACKAGE )
2643
                    if ( p != null )
2647
                    {
2644
                    {
2648
                        p.addDependency(pkg_name + v_ext, dpv_id );
2645
                        p.addDependency(pkg_name + v_ext, dpv_id );
2649
                    }
2646
                    }
2650
 
2647
 
2651
                }
2648
                }
Line 2679... Line 2676...
2679
                {
2676
                {
2680
                    int pv_id = rset10.mustGetKeyInt("pv_id");
2677
                    int pv_id = rset10.mustGetKeyInt("pv_id");
2681
                    String bm_name = rset10.mustGetString("bm_name");
2678
                    String bm_name = rset10.mustGetString("bm_name");
2682
                    String bsa_name = rset10.mustGetString("bsa_name");
2679
                    String bsa_name = rset10.mustGetString("bsa_name");
2683
 
2680
 
2684
                    Package p = findPackage(pv_id, packageCollection);
2681
                    Package p = packageCollection.contains(pv_id);
2685
                    if ( p != NULL_PACKAGE )
2682
                    if ( p != null )
2686
                    {
2683
                    {
2687
                        BuildStandard bs = new BuildStandard(rippleEngine, bm_name, bsa_name);
2684
                        BuildStandard bs = new BuildStandard(rippleEngine, bm_name, bsa_name);
2688
                        if ( bs.supportedBuildStandard() )
2685
                        if ( bs.supportedBuildStandard() )
2689
                        {
2686
                        {
2690
                            p.mBuildStandardCollection.add(bs);
2687
                            p.mBuildStandardCollection.add(bs);
Line 2711... Line 2708...
2711
 
2708
 
2712
                while( rset11.next() )
2709
                while( rset11.next() )
2713
                {
2710
                {
2714
                    int pv_id = rset11.mustGetKeyInt("pv_id");
2711
                    int pv_id = rset11.mustGetKeyInt("pv_id");
2715
                    String test_type_name = rset11.mustGetString("test_type_name");
2712
                    String test_type_name = rset11.mustGetString("test_type_name");
2716
                    Package p = findPackage(pv_id, packageCollection);
2713
                    Package p = packageCollection.contains(pv_id);
2717
                    if ( p != NULL_PACKAGE )
2714
                    if ( p != null )
2718
                    {
2715
                    {
2719
                        if ( test_type_name.compareTo("Autobuild UTF") == 0 )
2716
                        if ( test_type_name.compareTo("Autobuild UTF") == 0 )
2720
                        {
2717
                        {
2721
                            p.mHasAutomatedUnitTests = true;
2718
                            p.mHasAutomatedUnitTests = true;
2722
                        }
2719
                        }
Line 2754... Line 2751...
2754
 
2751
 
2755
                while( rset12.next() )
2752
                while( rset12.next() )
2756
                {
2753
                {
2757
                    int pv_id = rset12.mustGetKeyInt("pv_id");
2754
                    int pv_id = rset12.mustGetKeyInt("pv_id");
2758
                    String user_email = rset12.getString("user_email",null);
2755
                    String user_email = rset12.getString("user_email",null);
2759
                    Package p = findPackage(pv_id, packageCollection);
2756
                    Package p = packageCollection.contains(pv_id);
2760
 
-
 
2761
                    if ( p != NULL_PACKAGE )
2757
                    if ( p != null )
2762
                    {
2758
                    {
2763
                        p.addEmail(user_email);
2759
                        p.addEmail(user_email);
2764
                    }
2760
                    }
2765
                }
2761
                }
2766
 
2762
 
Line 2782... Line 2778...
2782
                RmResultSet rset14 = new RmResultSet(stmt14.executeQuery(), "queryPackageVersions rset14");
2778
                RmResultSet rset14 = new RmResultSet(stmt14.executeQuery(), "queryPackageVersions rset14");
2783
 
2779
 
2784
                while( rset14.next() )
2780
                while( rset14.next() )
2785
                {
2781
                {
2786
                    int pv_id = rset14.mustGetInt("pv_id");
2782
                    int pv_id = rset14.mustGetInt("pv_id");
2787
                    Package p = findPackage(pv_id, packageCollection);
2783
                    Package p = packageCollection.contains(pv_id);
2788
                    if ( p != NULL_PACKAGE )
2784
                    if ( p != null )
2789
                    {
2785
                    {
2790
                        p.mAdvisoryRipple = true;
2786
                        p.mAdvisoryRipple = true;
2791
                    }
2787
                    }
2792
                }
2788
                }
2793
 
2789
 
Line 2825... Line 2821...
2825
                    String pkg_name = rset.mustGetString("pkg_name");
2821
                    String pkg_name = rset.mustGetString("pkg_name");
2826
                    String pkg_version = rset.mustGetString("pkg_version");
2822
                    String pkg_version = rset.mustGetString("pkg_version");
2827
                    String v_ext = rset.getString("v_ext", "");
2823
                    String v_ext = rset.getString("v_ext", "");
2828
                    String vcs_tag = rset.getString("vcsTag","");
2824
                    String vcs_tag = rset.getString("vcsTag","");
2829
                    
2825
                    
2830
                    Package p = findPackage(pv_id, packageCollection);
2826
                    Package p = packageCollection.contains(pv_id);
2831
                    if ( p == NULL_PACKAGE )
2827
                    if ( p == null )
2832
                    {
2828
                    {
2833
                        Package q = new Package(0, pv_id, pkg_name, pkg_version, v_ext, pkg_name + "." + pkg_version, vcs_tag, 'x');
2829
                        Package q = new Package(0, pv_id, pkg_name, pkg_version, v_ext, pkg_name + "." + pkg_version, vcs_tag, 'x');
2834
                        packageCollection.add(q);
2830
                        packageCollection.add(q);
2835
                    }
2831
                    }
2836
                }
2832
                }
Line 2874... Line 2870...
2874
     * @param   baseline            - RtagId of the release being processed, BomId of an Escrow being processed
2870
     * @param   baseline            - RtagId of the release being processed, BomId of an Escrow being processed
2875
     *  
2871
     *  
2876
     * Overridden in ReleaseManagerUtf
2872
     * Overridden in ReleaseManagerUtf
2877
     *  
2873
     *  
2878
     */
2874
     */
2879
    protected void queryWips(RippleEngine rippleEngine, ArrayList<Package> packageCollection, int baseline) throws SQLException, Exception
2875
    protected void queryWips(RippleEngine rippleEngine, PackageCollection packageCollection, int baseline) throws SQLException, Exception
2880
    {
2876
    {
2881
        if (!mDaemon){
2877
        if (!mDaemon){
2882
            return;
2878
            return;
2883
        }
2879
        }
2884
        
2880
        
Line 2920... Line 2916...
2920
 
2916
 
2921
                    // If there are multiple packages with the same Alias, then only the first one
2917
                    // If there are multiple packages with the same Alias, then only the first one
2922
                    // will be placed in the build set. The will be the oldest, the first one released
2918
                    // will be placed in the build set. The will be the oldest, the first one released
2923
                    // to be built
2919
                    // to be built
2924
 
2920
 
2925
                    Package prevPlannedPackage = findPackage(p.mAlias, packageCollection);
2921
                    Package prevPlannedPackage = packageCollection.contains(p.mAlias);
2926
                    if ( prevPlannedPackage == NULL_PACKAGE )
2922
                    if ( prevPlannedPackage == null )
2927
                    {
2923
                    {
2928
                        mLogger.debug("queryWips rset1 no previous WIP package {}", pvId);
2924
                        mLogger.debug("queryWips rset1 no previous WIP package {}", pvId);
2929
                        packageCollection.add(p);
2925
                        packageCollection.add(p);
2930
                    }
2926
                    }
2931
                }
2927
                }
Line 2953... Line 2949...
2953
            
2949
            
2954
            phase.setPhase("getSchedBuilds");
2950
            phase.setPhase("getSchedBuilds");
2955
            di = new DaemonInstruction(baseline, 2, false);
2951
            di = new DaemonInstruction(baseline, 2, false);
2956
            while ( getDaemonInst( di ) )
2952
            while ( getDaemonInst( di ) )
2957
            {
2953
            {
2958
                Package p = findPackage(di.pvId, packageCollection);
2954
                Package p = packageCollection.contains(di.pvId); 
2959
 
-
 
2960
                if ( p != NULL_PACKAGE )
2955
                if ( p != null )
2961
                {
2956
                {
2962
                    mLogger.info("queryPackageVersions Scheduled Build Approvals {}", di.pvId);
2957
                    mLogger.info("queryPackageVersions Scheduled Build Approvals {}", di.pvId);
2963
                    packageCollection.remove(p);
2958
                    packageCollection.remove(p);
2964
                }
2959
                }
2965
                else
2960
                else
Line 2987... Line 2982...
2987
     * @param   baseline            - RtagId of the release being processed, BomId of an Escrow being processed
2982
     * @param   baseline            - RtagId of the release being processed, BomId of an Escrow being processed
2988
     *  
2983
     *  
2989
     * Overridden in ReleaseManagerUtf
2984
     * Overridden in ReleaseManagerUtf
2990
     *  
2985
     *  
2991
     */
2986
     */
2992
    protected void queryTest(RippleEngine rippleEngine, ArrayList<Package> packageCollection, int baseline) throws SQLException, Exception
2987
    protected void queryTest(RippleEngine rippleEngine, PackageCollection packageCollection, int baseline) throws SQLException, Exception
2993
    {
2988
    {
2994
        if (!mDaemon){
2989
        if (!mDaemon){
2995
            return;
2990
            return;
2996
        }
2991
        }
2997
        
2992
        
Line 3031... Line 3026...
3031
                {
3026
                {
3032
                    packageCollection.add(p);
3027
                    packageCollection.add(p);
3033
                    
3028
                    
3034
                    //  Set some Test information
3029
                    //  Set some Test information
3035
                    //  Avoid interaction with real versions
3030
                    //  Avoid interaction with real versions
3036
                    //  Flag as not pegged - so that we test build
3031
                    //  Flag as not peg ed - so that we test build
3037
                    p.mVersion = "0.0.0000";
-
 
-
 
3032
 
3038
                    p.mTestBuildInstruction = di.instruction;
3033
                    p.mTestBuildInstruction = di.instruction;
3039
                    p.addEmail(di.userEmail);
3034
                    p.addEmail(di.userEmail);
3040
                    p.mBuildReason = BuildReason.Test;
3035
                    p.mBuildReason = BuildReason.Test;
3041
                    p.mIsPegged = false;
3036
                    p.mIsPegged = false;
3042
                    p.mIsNotReleased = true;
3037
                    p.mIsNotReleased = true;
Line 3060... Line 3055...
3060
     * @param   baseline            - RtagId of the release being processed, BomId of an Escrow being processed
3055
     * @param   baseline            - RtagId of the release being processed, BomId of an Escrow being processed
3061
     *  
3056
     *  
3062
     * Overridden in ReleaseManagerUtf
3057
     * Overridden in ReleaseManagerUtf
3063
     *  
3058
     *  
3064
     */
3059
     */
3065
    protected void queryRipples(RippleEngine rippleEngine, ArrayList<Package> packageCollection, int baseline) throws SQLException, Exception
3060
    protected void queryRipples(RippleEngine rippleEngine, PackageCollection packageCollection, int baseline) throws SQLException, Exception
3066
    {
3061
    {
3067
        if (!mDaemon){
3062
        if (!mDaemon){
3068
            return;
3063
            return;
3069
        }
3064
        }
3070
        
3065
        
Line 3548... Line 3543...
3548
     *   @param checkCollection     - How to handle pkg not in the collection. False: Process all package dependencies. True: Skip if package is in collection
3543
     *   @param checkCollection     - How to handle pkg not in the collection. False: Process all package dependencies. True: Skip if package is in collection
3549
     *   @param listIterator        - List iterator being used to iterate over packageCollection. Used to insert new packages
3544
     *   @param listIterator        - List iterator being used to iterate over packageCollection. Used to insert new packages
3550
     *   
3545
     *   
3551
     *   This function is called recursively
3546
     *   This function is called recursively
3552
     */
3547
     */
3553
    private void traverseDependencies(ArrayList<Package> packageCollection, Package pkg, boolean checkCollection, ListIterator<Package> listIterator) throws SQLException, Exception
3548
    private void traverseDependencies(PackageCollection packageCollection, Package pkg, boolean checkCollection, ListIterator<Package> listIterator) throws SQLException, Exception
3554
    {
3549
    {
-
 
3550
// TODO - this needs some work and some testing    	
3555
        mLogger.debug("traverseDependencies {}", checkCollection);
3551
        mLogger.debug("traverseDependencies {}", checkCollection);
3556
        boolean pvIdInCollection = false;
3552
        boolean pvIdInCollection = false;
3557
 
3553
 
3558
        if ( checkCollection )
3554
        if ( checkCollection )
3559
        {
3555
        {
3560
            for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
3556
        	Package p = packageCollection.contains(pkg.mId);
3561
            {
-
 
3562
                Package p = it.next();
-
 
3563
 
-
 
3564
                if ( p.mId == pkg.mId )
-
 
3565
                {
3557
        	if (p != null)
3566
                    pvIdInCollection = true;
3558
        		pvIdInCollection = true;
3567
                    break;
-
 
3568
                }
-
 
3569
            }
-
 
3570
        }
3559
        }
3571
 
3560
 
3572
        if ( !pvIdInCollection )
3561
        if ( !pvIdInCollection )
3573
        {
3562
        {
3574
            ArrayList<Package> resultset = new ArrayList<Package>();
3563
            ArrayList<Package> resultset = new ArrayList<Package>();
Line 3620... Line 3609...
3620
            {
3609
            {
3621
                Package r = it.next();
3610
                Package r = it.next();
3622
                traverseDependencies(packageCollection, r, true, listIterator);
3611
                traverseDependencies(packageCollection, r, true, listIterator);
3623
 
3612
 
3624
                pvIdInCollection = false;
3613
                pvIdInCollection = false;
3625
 
-
 
3626
                for (Iterator<Package> it2 = packageCollection.iterator(); it2.hasNext();)
3614
                Package p = packageCollection.contains(r.mId);
3627
                {
-
 
3628
                    Package p = it2.next();
-
 
3629
 
-
 
3630
                    if (p.mId == r.mId)
-
 
3631
                    {
3615
            	if (p != null)
3632
                        pvIdInCollection = true;
3616
            		pvIdInCollection = true;
3633
                        break;
-
 
3634
                    }
-
 
3635
                }
3617
                
3636
 
-
 
3637
                if (!pvIdInCollection)
3618
                if (!pvIdInCollection)
3638
                {
3619
                {
3639
                    // insert the Package immediately before the next Package returned by next
3620
                    // insert the Package immediately before the next Package returned by next
3640
                    // this does not change the next Package (if any) to be returned by next
3621
                    // this does not change the next Package (if any) to be returned by next
3641
                    listIterator.add(r);
3622
                    listIterator.add(r);
Line 3695... Line 3676...
3695
            handleSQLException(e, "");
3676
            handleSQLException(e, "");
3696
        }
3677
        }
3697
 
3678
 
3698
    }
3679
    }
3699
 
3680
 
3700
    /**
-
 
3701
     * Find Package by pvid
-
 
3702
     * @param   id                  - pvid of package to locate
-
 
3703
     * @param   packageCollection   - Collection to scan
-
 
3704
     * @return  Package with the matching mID or NULL_PACKAGE if no package has the mID
-
 
3705
     */
-
 
3706
    int findPackageLastId = 0;
-
 
3707
    int findPackageLastIndex = 0;
-
 
3708
    Package findPackageLastPackage = NULL_PACKAGE;
-
 
3709
    
-
 
3710
    /**
-
 
3711
     * Reset the values cached by findPackage
-
 
3712
     * Needed when a new plan is started as the only package versions are stale
-
 
3713
     */
-
 
3714
    public void findPackageResetCache() {
-
 
3715
        findPackageLastId = 0;
-
 
3716
        findPackageLastIndex = 0;
-
 
3717
        findPackageLastPackage = NULL_PACKAGE;
-
 
3718
    }
-
 
3719
 
-
 
3720
    public Package findPackage(int id, ArrayList<Package> packageCollection)
-
 
3721
    {
-
 
3722
        mLogger.debug("findPackage id {}", id);
-
 
3723
        Package retVal = NULL_PACKAGE;
-
 
3724
        
-
 
3725
        if (findPackageLastId != 0 && findPackageLastId == id) {
-
 
3726
            mLogger.debug("findPackage id {} - cache hit", id);
-
 
3727
            retVal = findPackageLastPackage;
-
 
3728
        }
-
 
3729
        else
-
 
3730
        {
-
 
3731
            int index = 0;
-
 
3732
            findPackageLastIndex = -1;
-
 
3733
            
-
 
3734
            for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); index++ )
-
 
3735
            {
-
 
3736
                Package p = it.next();
-
 
3737
    
-
 
3738
                if ( p.mId == id )
-
 
3739
                {
-
 
3740
                    findPackageLastId = id;
-
 
3741
                    findPackageLastPackage = p;
-
 
3742
                    findPackageLastIndex = index;
-
 
3743
                    retVal = p;
-
 
3744
                    break;
-
 
3745
                }
-
 
3746
            }
-
 
3747
        }
-
 
3748
 
-
 
3749
        mLogger.debug("findPackage id {} returned {}", id, retVal.mName);
-
 
3750
        return retVal;
-
 
3751
    }
-
 
3752
 
-
 
3753
    /**
-
 
3754
     * Find Package by package alias
-
 
3755
     * @param   alias               - alias of package to locate
-
 
3756
     * @param   packageCollection   - Collection to scan
-
 
3757
     * @return  Package with the matching mAlias or NULL_PACKAGE if no package has the mAlias
-
 
3758
     */
-
 
3759
    protected Package findPackage(String alias, ArrayList<Package> packageCollection)
-
 
3760
    {
-
 
3761
        mLogger.debug("findPackage alias {}", alias);
-
 
3762
        Package retVal = NULL_PACKAGE;
-
 
3763
        int index = 0;
-
 
3764
        findPackageLastIndex = -1;
-
 
3765
 
-
 
3766
        for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); index++)
-
 
3767
        {
-
 
3768
            Package p = it.next();
-
 
3769
 
-
 
3770
            if ( p.mAlias.compareTo( alias ) == 0 )
-
 
3771
            {
-
 
3772
                retVal = p;
-
 
3773
                findPackageLastId = p.mId;
-
 
3774
                findPackageLastPackage = p;
-
 
3775
                findPackageLastIndex = index;
-
 
3776
                break;
-
 
3777
            }
-
 
3778
        }
-
 
3779
 
-
 
3780
        mLogger.info("findPackage alias {} returned {}", alias, retVal.mName);
-
 
3781
        return retVal;
-
 
3782
    }
-
 
3783
    
-
 
3784
    
-
 
3785
 
-
 
3786
    /**only used in daemon mode to determine version existence in the database
3681
    /**only used in daemon mode to determine version existence in the database
3787
     *  1 select pkg_id from release_manager.package_versions where pkg_id=<pkg_id> and pkg_version=<pkg_version>;
3682
     *  1 select pkg_id from release_manager.package_versions where pkg_id=<pkg_id> and pkg_version=<pkg_version>;
3788
     *  2 select pkg_id from release_manager.planned_versions where pkg_id=<pkg_id> and pkg_version=<pkg_version>;
3683
     *  2 select pkg_id from release_manager.planned_versions where pkg_id=<pkg_id> and pkg_version=<pkg_version>;
3789
     * returns true if either resultset contains one record to indicate it already exists
3684
     * returns true if either resultset contains one record to indicate it already exists
3790
     */
3685
     */