Subversion Repositories DevTools

Rev

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

Rev 7176 Rev 7186
Line 76... Line 76...
76
     */
76
     */
77
    private String mEscrowRawData;
77
    private String mEscrowRawData;
78
 
78
 
79
    /** Collections of packages
79
    /** Collections of packages
80
     */
80
     */
81
    private ArrayList<Package> mPackageCollection = new ArrayList<Package>();
81
    private PackageCollection mPackageCollection = new PackageCollection();
82
    private ArrayList<Package> mPackageCollectionWip = new ArrayList<Package>();
82
    private PackageCollection mPackageCollectionWip = new PackageCollection();
83
    private ArrayList<Package> mPackageCollectionTest = new ArrayList<Package>();
83
    private PackageCollection mPackageCollectionTest = new PackageCollection();
84
    private ArrayList<Package> mPackageCollectionRipple = new ArrayList<Package>();
84
    private PackageCollection mPackageCollectionRipple = new PackageCollection();
85
    private ArrayList<Package> mPackageCollectionAll = new ArrayList<Package>();
85
    private PackageCollection mPackageCollectionAll = new PackageCollection();
86
    
-
 
87
 
86
 
88
    /**index to current String item
87
    /**index to current String item
89
     * @attribute
88
     * @attribute
90
     */
89
     */
91
    private int mBuildIndex;
90
    private int mBuildIndex;
Line 320... Line 319...
320
            
319
            
321
            // Sort the collection by PVID
320
            // Sort the collection by PVID
322
            //      Unit Test output order is known
321
            //      Unit Test output order is known
323
            //      May assist in creating repeatable build orders
322
            //      May assist in creating repeatable build orders
324
            //
323
            //
325
            Collections.sort(mPackageCollectionAll, Package.SeqComparator);
324
            Collections.sort(mPackageCollectionAll.mCollection, Package.SeqComparator);
326
 
325
 
327
            //------------------------------------------------------------------------
326
            //------------------------------------------------------------------------
328
            //    Process packages collected
327
            //    Process packages collected
329
            //    Determine and tag those we can't build
328
            //    Determine and tag those we can't build
330
            phase.setPhase("processPackages");
329
            phase.setPhase("processPackages");
Line 451... Line 450...
451
            Package p = it.next();
450
            Package p = it.next();
452
 
451
 
453
            for (Iterator<PkgDependency> it2 = p.mDependencyCollection.iterator(); it2.hasNext(); )
452
            for (Iterator<PkgDependency> it2 = p.mDependencyCollection.iterator(); it2.hasNext(); )
454
            {
453
            {
455
                PkgDependency depEntry = it2.next();
454
                PkgDependency depEntry = it2.next();
456
                Package dependency = findPackage(depEntry.alias);
455
                Package dependency = mPackageCollection.contains(depEntry.alias);
-
 
456
                if (dependency != null)
457
                depEntry.pkg = dependency;
457
                	depEntry.pkg = dependency;
458
            }
458
            }
459
        }    
459
        }    
460
 
460
 
461
        // Detect and deal with circular dependencies
461
        // Detect and deal with circular dependencies
462
        // Examine all packages under consideration
462
        // Examine all packages in the Release. Other packages will be examined later
463
        //
-
 
464
        phase.setPhase("Detect Circular Dependencies");
463
        phase.setPhase("Detect Circular Dependencies");
465
        mLogger.debug("planRelease deal with circular dependencies");
464
        mLogger.debug("planRelease deal with circular dependencies");
466
        for (Iterator<Package> it = mPackageCollectionAll.iterator(); it.hasNext(); )
465
        for (Iterator<Package> it = mPackageCollectionAll.iterator(); it.hasNext(); )
467
        {
466
        {
468
            Package p = it.next();
467
            Package p = it.next();
469
 
468
 
470
            if ( p.hasCircularDependency( mPackageCollectionAll ) )
469
            if ( p.hasCircularDependency( mPackageCollection ) )
471
            {
470
            {
472
                mLogger.info("planRelease circular dependency detected {}", p.mAlias);
471
                mLogger.info("planRelease circular dependency detected {}", p.mAlias);
473
                
472
                
474
                //  Force this package to be marked as having a circular dependency - even if its been excluded
473
                //  Force this package to be marked as having a circular dependency - even if its been excluded
475
                p.mBuildFile = 0;
474
                p.mBuildFile = 0;
Line 504... Line 503...
504
            }
503
            }
505
 
504
 
506
            for (Iterator<PkgDependency> it2 = p.mDependencyCollection.iterator(); it2.hasNext(); )
505
            for (Iterator<PkgDependency> it2 = p.mDependencyCollection.iterator(); it2.hasNext(); )
507
            {
506
            {
508
                PkgDependency depEntry = it2.next();
507
                PkgDependency depEntry = it2.next();
509
                Package dependency = findPackage(depEntry.alias);
508
                Package dependency = mPackageCollection.contains(depEntry.alias);
510
 
509
 
511
                if (dependency == ReleaseManager.NULL_PACKAGE)
510
                if (dependency == null)
512
                {
511
                {
513
                    mLogger.info("planRelease dependency is not in the baseline {}", depEntry);
512
                    mLogger.info("planRelease dependency is not in the baseline {}", depEntry);
514
                    // Exclude the package
513
                    // Exclude the package
515
                    // max 50 chars
514
                    // max 50 chars
516
                    rippleBuildExclude(p, p.mId, "Package build dependency not in the release", -4);
515
                    rippleBuildExclude(p, p.mId, "Package build dependency not in the release", -4);
Line 1103... Line 1102...
1103
                    //  Ensure that the package we are about to build is present in the mPackageCollection as its
1102
                    //  Ensure that the package we are about to build is present in the mPackageCollection as its
1104
                    //  this list that is used to generate the build.xml file - that may be a bad way to do it , but ...
1103
                    //  this list that is used to generate the build.xml file - that may be a bad way to do it , but ...
1105
                    //
1104
                    //
1106
                    //  Note: Can't really modify others as they will be used as dependencies
1105
                    //  Note: Can't really modify others as they will be used as dependencies
1107
                    //
1106
                    //
1108
                    Package pEntry = findPackage(build.mAlias);
-
 
1109
                    if ( pEntry != ReleaseManager.NULL_PACKAGE)
-
 
1110
                    {
-
 
1111
                        mPackageCollection.set(mReleaseManager.findPackageLastIndex, build);
-
 
1112
                        build.mIsNotReleased = false;
-
 
1113
                    } else {
-
 
1114
                        mPackageCollection.add(build);
1107
                    mPackageCollection.upsert(build);
1115
                        build.mIsNotReleased = false;
1108
                    build.mIsNotReleased = false;
1116
                    }
-
 
1117
                }
1109
                }
1118
 
1110
 
1119
                //
1111
                //
1120
                //  Report packages that are indirectly excluded
1112
                //  Report packages that are indirectly excluded
1121
                //  ie: They will not be built because one, or more, of their dependents is not buildable
1113
                //  ie: They will not be built because one, or more, of their dependents is not buildable
Line 1145... Line 1137...
1145
                                // package is not reproducible, discard it and its consumers
1137
                                // package is not reproducible, discard it and its consumers
1146
                                //
1138
                                //
1147
                                mLogger.warn("Excluded Package {}, {}", p, be );                                     
1139
                                mLogger.warn("Excluded Package {}, {}", p, be );                                     
1148
 
1140
 
1149
                                ArrayList<Package> toExclude = new ArrayList<Package>();
1141
                                ArrayList<Package> toExclude = new ArrayList<Package>();
1150
                                toExclude.addAll(usedByAnyPackages(p, mPackageCollectionAll ));
1142
                                toExclude.addAll(usedByAnyPackages(p, mPackageCollection ));
1151
 
1143
 
1152
                                //  Process packages that we need to exclude indirectly
1144
                                //  Process packages that we need to exclude indirectly
1153
                                //
1145
                                //
1154
                                while ( ! toExclude.isEmpty())
1146
                                while ( ! toExclude.isEmpty())
1155
                                {
1147
                                {
Line 1185... Line 1177...
1185
                                        pkg.mBuildFile = -5; 
1177
                                        pkg.mBuildFile = -5; 
1186
                                    }
1178
                                    }
1187
 
1179
 
1188
                                    // Determine all packages that use this excluded package
1180
                                    // Determine all packages that use this excluded package
1189
                                    // THAT WE HAVE NOT ALREADY PROCESSED - circular dependencies are a killer
1181
                                    // THAT WE HAVE NOT ALREADY PROCESSED - circular dependencies are a killer
1190
                                    ArrayList<Package> usedBy = usedByAnyPackages(pkg, mPackageCollectionAll );
1182
                                    ArrayList<Package> usedBy = usedByAnyPackages(pkg, mPackageCollection );
1191
                                    for (Iterator<Package> it2 = usedBy.iterator(); it2.hasNext(); )
1183
                                    for (Iterator<Package> it2 = usedBy.iterator(); it2.hasNext(); )
1192
                                    {
1184
                                    {
1193
                                        Package uPkg = it2.next();
1185
                                        Package uPkg = it2.next();
1194
                                        if (!uPkg.mCheckedCircularDependency)
1186
                                        if (!uPkg.mCheckedCircularDependency)
1195
                                        {
1187
                                        {
Line 1328... Line 1320...
1328
     * @param packageCollection - Base collection of packages to plan
1320
     * @param packageCollection - Base collection of packages to plan
1329
     * @param mode - true: Include 'Ripples'
1321
     * @param mode - true: Include 'Ripples'
1330
     * 
1322
     * 
1331
     * @return
1323
     * @return
1332
     */
1324
     */
1333
    private PlanResults planCollection(String name, ArrayList<Package> packageCollection, boolean mode)
1325
    private PlanResults planCollection(String name, PackageCollection packageCollection, boolean mode)
1334
    {
1326
    {
1335
        Phase phase = new Phase("Plan-" + name); 
1327
        Phase phase = new Phase("Plan-" + name); 
1336
        ArrayList<PlannedPackage> ripplePlan = new ArrayList<PlannedPackage>();
1328
        ArrayList<PlannedPackage> ripplePlan = new ArrayList<PlannedPackage>();
1337
        PlanResults results = new PlanResults();
1329
        PlanResults results = new PlanResults();
1338
 
1330
 
Line 1590... Line 1582...
1590
     *                          as a part of the basic plan
1582
     *                          as a part of the basic plan
1591
     * @return
1583
     * @return
1592
     */
1584
     */
1593
    private PlanResults postRipplePlan(String name, PlanResults basicPlan, boolean mode) {
1585
    private PlanResults postRipplePlan(String name, PlanResults basicPlan, boolean mode) {
1594
 
1586
 
1595
        ArrayList<Package> fullPlanCollection = new ArrayList<Package>(mPackageCollection);
1587
        PackageCollection fullPlanCollection = new PackageCollection(mPackageCollection);
1596
        ArrayList<Package> buildCandidates = new ArrayList<Package>();
1588
        ArrayList<Package> buildCandidates = new ArrayList<Package>();
1597
        buildCandidates.addAll(mPackageCollectionWip);
1589
        buildCandidates.addAll(mPackageCollectionWip.mCollection);
1598
        buildCandidates.addAll(mPackageCollectionRipple);
1590
        buildCandidates.addAll(mPackageCollectionRipple.mCollection);
1599
        
1591
        
1600
        if ( !buildCandidates.isEmpty() )
1592
        if ( !buildCandidates.isEmpty() )
1601
        {
1593
        {
1602
            for (Iterator<Package> it = buildCandidates.iterator(); it.hasNext(); )
1594
            for (Iterator<Package> it = buildCandidates.iterator(); it.hasNext(); )
1603
            {
1595
            {
Line 1605... Line 1597...
1605
                if (p.mBuildFile >= 0)
1597
                if (p.mBuildFile >= 0)
1606
                {
1598
                {
1607
                    if (!mode)
1599
                    if (!mode)
1608
                    {
1600
                    {
1609
                        //  Exclude packages that would have been processed in the basicPlan
1601
                        //  Exclude packages that would have been processed in the basicPlan
-
 
1602
                    	// TODO - Don't like scanning. SHould have a collection with a hash
1610
                        for (Iterator<PlannedPackage> it1 = basicPlan.planCollection.iterator(); it1.hasNext(); )
1603
                        for (Iterator<PlannedPackage> it1 = basicPlan.planCollection.iterator(); it1.hasNext(); )
1611
                        {
1604
                        {
1612
                            PlannedPackage pkg = it1.next();
1605
                            PlannedPackage pkg = it1.next();
1613
                            if (pkg.mPkg == p)
1606
                            if (pkg.mPkg == p)
1614
                            {
1607
                            {
Line 1617... Line 1610...
1617
                            }
1610
                            }
1618
                        }
1611
                        }
1619
                    }
1612
                    }
1620
                    
1613
                    
1621
                    mLogger.warn("Test Plan with {}", p);
1614
                    mLogger.warn("Test Plan with {}", p);
1622
                    Package foundInRelease = mReleaseManager.findPackage(p.mAlias, fullPlanCollection);
-
 
1623
                    int foundIndex = mReleaseManager.findPackageLastIndex;
-
 
1624
                    if (foundInRelease == ReleaseManager.NULL_PACKAGE)
-
 
1625
                    {
-
 
1626
                        fullPlanCollection.add(p);
1615
                    fullPlanCollection.upsert(p);
1627
                    }
-
 
1628
                    else
-
 
1629
                    {
-
 
1630
                        fullPlanCollection.set(foundIndex, p);
-
 
1631
                    }
-
 
1632
                    
-
 
-
 
1616
 
1633
                    Package.resetCircularDependency (fullPlanCollection);
1617
                    Package.resetCircularDependency (fullPlanCollection);
1634
                    if ( p.hasCircularDependency( fullPlanCollection ) )
1618
                    if ( p.hasCircularDependency( fullPlanCollection ) )
1635
                    {
1619
                    {
1636
                        mLogger.info("planRelease circular dependency detected {}", p);
1620
                        mLogger.info("planRelease circular dependency detected {}", p);
1637
                        
1621
                        
Line 1690... Line 1674...
1690
    
1674
    
1691
    /** 
1675
    /** 
1692
     *  Calculate a collection of packages that use the named package
1676
     *  Calculate a collection of packages that use the named package
1693
     *   
1677
     *   
1694
     * @param pkg - Package to process
1678
     * @param pkg - Package to process
1695
     * @param pkgCollection - collection of packages to scan
1679
     * @param packageCollection - collection of packages to scan
1696
     *
1680
     *
1697
     * @return A collection of packages that actively 'use' the specified package
1681
     * @return A collection of packages that actively 'use' the specified package
1698
 
1682
 
1699
     */
1683
     */
1700
    private ArrayList<Package> usedByAnyPackages(Package pkg, ArrayList<Package> pkgCollection) {
1684
    private ArrayList<Package> usedByAnyPackages(Package pkg, PackageCollection packageCollection) {
1701
        
1685
        
1702
        ArrayList<Package> usedBy = new ArrayList<Package>();
1686
        ArrayList<Package> usedBy = new ArrayList<Package>();
1703
        
1687
        
1704
        for (Iterator<Package> it = pkgCollection.iterator(); it.hasNext(); )
1688
        for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
1705
        {
1689
        {
1706
            Package p = it.next();
1690
            Package p = it.next();
1707
            
1691
            
1708
            for (Iterator<PkgDependency> it2 = p.mDependencyCollection.iterator(); it2.hasNext(); )
1692
            for (Iterator<PkgDependency> it2 = p.mDependencyCollection.iterator(); it2.hasNext(); )
1709
            {
1693
            {
Line 1724... Line 1708...
1724
     *  
1708
     *  
1725
     *  These need o be rejected now as the the Master logic will plan a build a build if there is a daemon instruction
1709
     *  These need o be rejected now as the the Master logic will plan a build a build if there is a daemon instruction
1726
     *  present. If an instruction cannot be processed and is not removed, then the daemon will continuously 'plan'
1710
     *  present. If an instruction cannot be processed and is not removed, then the daemon will continuously 'plan'
1727
     */
1711
     */
1728
    private void reportUnsatisfiedDaemonInstructions() throws SQLException, Exception {
1712
    private void reportUnsatisfiedDaemonInstructions() throws SQLException, Exception {
1729
        ArrayList<Package> toProcess = new ArrayList<Package>();
1713
        PackageCollection toProcess = new PackageCollection();
1730
        toProcess.addAll(mPackageCollectionTest);
1714
        toProcess.addAll(mPackageCollectionTest);
1731
        toProcess.addAll(mPackageCollectionRipple);
1715
        toProcess.addAll(mPackageCollectionRipple);
1732
    
1716
    
1733
        for (Iterator<Package> it = toProcess.iterator(); it.hasNext(); )
1717
        for (Iterator<Package> it = toProcess.iterator(); it.hasNext(); )
1734
        {
1718
        {
Line 1736... Line 1720...
1736
    
1720
    
1737
            //
1721
            //
1738
            //  If the package is in the 'plan, then its not excluded
1722
            //  If the package is in the 'plan, then its not excluded
1739
            //
1723
            //
1740
            boolean isPlanned = false;
1724
            boolean isPlanned = false;
-
 
1725
//TODO Should mBuildOrder be  aPackageCollection            
1741
            for (Iterator<PlannedPackage> it1 = mBuildOrder.listIterator(); it1.hasNext(); )
1726
            for (Iterator<PlannedPackage> it1 = mBuildOrder.listIterator(); it1.hasNext(); )
1742
            {
1727
            {
1743
                PlannedPackage pkg = it1.next();
1728
                PlannedPackage pkg = it1.next();
1744
                if (pkg.mPkg == p)
1729
                if (pkg.mPkg == p)
1745
                {
1730
                {
Line 1808... Line 1793...
1808
     * @param dpvId
1793
     * @param dpvId
1809
     * @return true - specified pvid is a full member of the Release
1794
     * @return true - specified pvid is a full member of the Release
1810
     */
1795
     */
1811
    private boolean isInRelease(Integer dpvId) {
1796
    private boolean isInRelease(Integer dpvId) {
1812
        
1797
        
1813
        boolean inRelease = false;
-
 
1814
 
-
 
1815
        for ( Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
1798
        boolean inRelease = ( mPackageCollection.contains(dpvId) != null);
1816
        {
-
 
1817
            Package p = it.next();
-
 
1818
 
-
 
1819
            if ( p.mId == dpvId )
-
 
1820
            {
-
 
1821
                inRelease = ! p.mIsNotReleased;
-
 
1822
                break;
-
 
1823
            }
-
 
1824
        }
-
 
1825
        return inRelease;
1799
        return inRelease;
1826
    }
1800
    }
1827
 
1801
 
1828
 
1802
 
1829
    /** Reports what change in build exceptions happens as part of planRelease
1803
    /** Reports what change in build exceptions happens as part of planRelease
Line 1867... Line 1841...
1867
 
1841
 
1868
            } else {
1842
            } else {
1869
                // Exclude and notify
1843
                // Exclude and notify
1870
                mLogger.warn("reportChange add new exclusion: {}", buildExclusion );
1844
                mLogger.warn("reportChange add new exclusion: {}", buildExclusion );
1871
                buildExclusion.excludeFromBuild(mReleaseManager, mBaseline);
1845
                buildExclusion.excludeFromBuild(mReleaseManager, mBaseline);
1872
                buildExclusion.email(this, mPackageCollectionAll);
1846
                buildExclusion.email(this, mPackageCollection);
1873
                counter++;
1847
                counter++;
1874
            }
1848
            }
1875
        }
1849
        }
1876
        mLogger.warn("reportChange exclusion count: {}", counter);
1850
        mLogger.warn("reportChange exclusion count: {}", counter);
1877
    }
1851
    }
Line 1982... Line 1956...
1982
            mReleaseManager.disconnect();
1956
            mReleaseManager.disconnect();
1983
        }
1957
        }
1984
    }
1958
    }
1985
 
1959
 
1986
    /**
1960
    /**
1987
     * Find Package by package alias
-
 
1988
     * Searches the released package collection
-
 
1989
     * @param   alias               - alias of package to locate
-
 
1990
     * @return  Package with the matching mAlias or NULL_PACKAGE if no package has the mAlias
-
 
1991
     */
-
 
1992
    public Package findPackage(String alias)
-
 
1993
    {
-
 
1994
        mLogger.debug("findPackage");
-
 
1995
 
-
 
1996
        Package retVal = mReleaseManager.findPackage(alias, mPackageCollection);
-
 
1997
 
-
 
1998
        mLogger.debug("findPackage returned {}", retVal.mName);
-
 
1999
        return retVal;
-
 
2000
    }
-
 
2001
    
-
 
2002
    /**
-
 
2003
     * Sets the mBuildFile to the specified value for the package
1961
     * Sets the mBuildFile to the specified value for the package
2004
     * Does not handle dependent packages - this will be done later  
1962
     * Does not handle dependent packages - this will be done later  
2005
     *  
1963
     *  
2006
     * @param p             The package being excluded 
1964
     * @param p             The package being excluded 
2007
     * @param rootPvId      The PVID of the package that is causing the exclusion. Null or -ve values are special
1965
     * @param rootPvId      The PVID of the package that is causing the exclusion. Null or -ve values are special