Subversion Repositories DevTools

Rev

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

Rev 7129 Rev 7133
Line 875... Line 875...
875
         * @throws SQLException
875
         * @throws SQLException
876
         */
876
         */
877
        private void planBuildOrder() throws Exception, SQLException 
877
        private void planBuildOrder() throws Exception, SQLException 
878
        {
878
        {
879
            
879
            
880
    /**
880
        /**
881
     * Current status
881
         * Current status
882
     *  basicPlan - time to complete current ripple
882
         *  basicPlan - time to complete current ripple
883
     *  FullPlan - Include all WIPS/RIPPLES into the release set
883
         *  FullPlan - Include all WIPS/RIPPLES into the release set
884
     *  
884
         *  
885
     *  If the full Plan does NOT extend the time of the basicPLan by 20% then use the full plan
885
         *  If the full Plan does NOT extend the time of the basicPLan by 20% then use the full plan
886
     *  otherwise complete the current ripple and the include WIPs/RIPPLEs\
886
         *  otherwise complete the current ripple and the include WIPs/RIPPLEs\
887
     *  
887
         *  
888
     *  TEST requests will be done first.
888
         *  TEST requests will be done first.
889
     *
889
         *
890
     */
890
         */
891
    
891
        
892
            // Process remaining packages which are need to be reproduced for this baseline.
892
            // Process remaining packages which are need to be reproduced for this baseline.
893
            //    Determine the build file for each package
893
            //    Determine the build file for each package
894
            //    For daemon builds:
894
            //    For daemon builds:
895
            //      Determine the next package that can be built now
895
            //      Determine the next package that can be built now
896
            //          Sounds simple - doesn't it
896
            //          Sounds simple - doesn't it
Line 934... Line 934...
934
                for (Iterator<Package> it = mPackageCollectionTest.iterator(); it.hasNext(); )
934
                for (Iterator<Package> it = mPackageCollectionTest.iterator(); it.hasNext(); )
935
                {
935
                {
936
                    Package p = it.next();
936
                    Package p = it.next();
937
                    if (p.mBuildFile >= 0)
937
                    if (p.mBuildFile >= 0)
938
                    {
938
                    {
939
                        mBuildOrder.add( new PlannedPackage(p,0 ) );
939
                        mBuildOrder.add( new PlannedPackage(p) );
940
                    }
940
                    }
941
                }
941
                }
942
                
942
                
943
                //  First attempt
943
                //  First attempt
944
                //  Insert all the WIPs and RIPPLES into the buildset. 
944
                //  Insert all the WIPs and RIPPLES into the buildset. 
Line 1249... Line 1249...
1249
            else
1249
            else
1250
            {
1250
            {
1251
                //  Escrow
1251
                //  Escrow
1252
                //  The basic plan is the escrow build order
1252
                //  The basic plan is the escrow build order
1253
                mBuildOrder = basicPlan.planCollection;
1253
                mBuildOrder = basicPlan.planCollection;
-
 
1254
                
-
 
1255
                for (Iterator<PlannedPackage> it = mBuildOrder.iterator(); it.hasNext(); )
-
 
1256
                {
-
 
1257
                    PlannedPackage p = it.next();
-
 
1258
                    p.mPkg.mNoBuildReason = p.mPkg.mBuildFile;
-
 
1259
                    p.mPkg.mBuildFile = p.mBuildLevel + 1;
-
 
1260
                }
1254
            }
1261
            }
1255
    
1262
    
1256
            mLogger.warn("Final Plan");
1263
            mLogger.warn("Final Plan");
1257
            for (Iterator<PlannedPackage> it = mBuildOrder.iterator(); it.hasNext(); )
1264
            for (Iterator<PlannedPackage> it = mBuildOrder.iterator(); it.hasNext(); )
1258
            {
1265
            {
Line 1369... Line 1376...
1369
                    }
1376
                    }
1370
                }
1377
                }
1371
            }
1378
            }
1372
        }
1379
        }
1373
        
1380
        
1374
        //  Now have a collection of packages with those that we cannot build have been marked
-
 
1375
        //  Process the list and determine packages that we can build right now
1381
        // Have a collection packages that we can build right now
1376
        //      ie: they have not been excluded, have not already been discovered and do not depend on any package in the collection
-
 
1377
        //      Continue to do this until all packages have been extracted
-
 
1378
        //      Allocate build levels as we go
-
 
1379
        //
-
 
1380
        phase.setPhase("Determine Build Order");
-
 
1381
        boolean allProcessed = false;
-
 
1382
        int buildLevel = 1;
-
 
1383
 
-
 
1384
        do
-
 
1385
        {
-
 
1386
            //
-
 
1387
            //  Create the mBuildOrder collection
1382
        // Create the ripplePlan
1388
            //      Same for both Daemon and Escrow modes
-
 
1389
            //      Will have package build order and build level
-
 
1390
            boolean allDependenciesProcessed = true;
-
 
1391
            do
-
 
1392
            {
-
 
1393
                allDependenciesProcessed = true;
-
 
1394
                for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
-
 
1395
                {
-
 
1396
                    Package p = it.next();
-
 
1397
                    
-
 
1398
                    //  Skip packages that have been processed - have determined build order, or cannot build
-
 
1399
                    if (p.mIsProcessed) {
-
 
1400
                        continue;
-
 
1401
                    }
-
 
1402
 
-
 
1403
                    // Package yet to be processed and
-
 
1404
                    //      Daemon mode: Could be built
-
 
1405
                    //      Escrow mode: Can be reproduced
-
 
1406
                    boolean canBeBuiltNow = true;
-
 
1407
                    boolean allDependenciesForThisPackageProcessed = true;
-
 
1408
 
-
 
1409
                    //  Scan the packages dependencies
-
 
1410
                    for ( Iterator<Package> it2 = p.mPackageDependencyCollection.iterator(); it2.hasNext(); )
-
 
1411
                    {
-
 
1412
                        Package dependency = it2.next();
-
 
1413
 
-
 
1414
                        if ( !dependency.mProcessed )
-
 
1415
                        {
-
 
1416
                            //  If all the dependencies have been processed, then we can potentially build this package
-
 
1417
                            //  If any of them have not been processed, then cannot calculate canBeBuiltNow until this 
-
 
1418
                            //  dependency has been processed
-
 
1419
                            allDependenciesForThisPackageProcessed = false;
-
 
1420
                            allDependenciesProcessed = false;
-
 
1421
                        }
-
 
1422
                        else if (  (  mDaemon && (   dependency.mBuildFile == 0 ) ||  (dependency.mBuildFile == buildLevel)) 
-
 
1423
                                || ( !mDaemon && ( ( dependency.mBuildFile == 0 ) ||
-
 
1424
                                                       ( dependency.mBuildFile == buildLevel &&
-
 
1425
                                                       ( !p.haveSameBuildStandards(dependency)  ) ) ) ) )
-
 
1426
                        {
-
 
1427
                            // Can be built - yet
-
 
1428
                            // Daemon mode:
-
 
1429
                            //    This processed dependency has not been assigned to a build iteration
-
 
1430
                            //    This processed dependency has been assigned to this build iteration
-
 
1431
                            // Escrow mode: This package cannot be built now if
-
 
1432
                            //    This processed dependency has not been assigned to a build iteration or
-
 
1433
                            //    This processed dependency has been assigned to this build iteration, but the 
-
 
1434
                            //    build standards of the package and this dependency prevent the package being
-
 
1435
                            //    built in this iteration.   
-
 
1436
                            canBeBuiltNow = false;
-
 
1437
                            mLogger.info("planRelease package cannot be built in this iteration {}", p.mName);
-
 
1438
                            break;
-
 
1439
                        }
-
 
1440
                    }
-
 
1441
 
1383
 
1442
                    //  All dependencies have been processed. May be able to build this package
-
 
1443
                    //      Add the package to the build order list
-
 
1444
                    //
-
 
1445
                    if (allDependenciesForThisPackageProcessed)
-
 
1446
                    {
-
 
1447
                        p.mProcessed = true;
-
 
1448
                        if ( canBeBuiltNow )
-
 
1449
                        {
-
 
1450
                            results.planCollection.add( new PlannedPackage(p, buildLevel));
-
 
1451
                            p.mBuildFile = buildLevel;
-
 
1452
                            p.mIsProcessed = true;
-
 
1453
                            mLogger.info("planRelease set mBuildFile to {} for package {}",buildLevel, p.mAlias );
-
 
1454
                        }
-
 
1455
                    }
-
 
1456
                }
-
 
1457
            } while( !allDependenciesProcessed );
-
 
1458
            
-
 
1459
            //  Have process all the packages that we can build at the moment
-
 
1460
            //      Examine all the packages in the collection to see if there are more that need to be extracted
-
 
1461
            //      These will be done at a different build-level
-
 
1462
            //  
-
 
1463
            allProcessed = true;
-
 
1464
            for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
-
 
1465
            {
-
 
1466
                Package p = it.next();
-
 
1467
                if ( !  p.mIsProcessed )
-
 
1468
                {
-
 
1469
                    // more build files are required
-
 
1470
                    allProcessed = false;
-
 
1471
                    mLogger.info("planRelease more build files are required for {}", p.mName);
-
 
1472
                    break;
-
 
1473
                }
-
 
1474
            }
-
 
1475
 
-
 
1476
            buildLevel++;
-
 
1477
            if (buildLevel % 500 == 0 ) {
-
 
1478
                mLogger.error("planRelease. Too many build levels {}", buildLevel);
-
 
1479
            }
-
 
1480
        } while( !allProcessed );
1384
        phase.setPhase("Calc Build Order");
1481
 
-
 
1482
        //  Now we have a collection packages that we can build right now
-
 
1483
        //      The packages currently have a build level set into mBuildFile
-
 
1484
        //
-
 
1485
        if (mDaemon)
1385
        if (mDaemon)
1486
        {
1386
        {
1487
            phase.setPhase("Calc Build Order");
1387
            ArrayList<PlannedPackage> toBuild = new ArrayList<PlannedPackage>();
-
 
1388
            
1488
            //
1389
            //
-
 
1390
            //  Daemon Mode
1489
            //  Determine if we have a reason to build anything in this collection of buildable packages
1391
            //  Determine if we have a reason to build anything in this collection of buildable packages
1490
            //      Reset the calculated buildLevel - It will be calculated again
-
 
1491
            //      Reset the mProcessed - it will be used to detect  that we have processed a package
1392
            //      Reset the mCheckedCircularDependency - it will be used to detect  that we have processed a package
1492
            
1393
            
1493
            ArrayList<PlannedPackage> toBuild = new ArrayList<PlannedPackage>();
-
 
1494
            for (Iterator<PlannedPackage> it = results.planCollection.iterator(); it.hasNext(); )
1394
            for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
1495
            {
1395
            {
1496
                PlannedPackage p = it.next();
1396
                Package p = it.next();
1497
                p.mBuildLevel = 0;
1397
                if (!p.mIsProcessed) {
-
 
1398
                    PlannedPackage pPkg = new PlannedPackage(p); 
-
 
1399
                    
-
 
1400
                    results.planCollection.add(pPkg);
1498
                p.mPkg.mCheckedCircularDependency = false;
1401
                    pPkg.mPkg.mCheckedCircularDependency = false;
1499
                
1402
                    
1500
                if (p.mPkg.mBuildReason != null) {
1403
                    if (p.mBuildReason != null) {
1501
                    if (mode || ( !mode && p.mPkg.mBuildReason != BuildReason.Ripple ))
1404
                        if (mode || ( !mode && p.mBuildReason != BuildReason.Ripple )) {
1502
                    {
1405
                            toBuild.add(pPkg);
1503
                        toBuild.add(p);
1406
                        }
1504
                    }
1407
                    }
1505
                }
1408
                }
1506
            }
1409
            }
1507
            
1410
            
1508
            //  Need (would like to) build stuff
1411
            //  Need (would like to) build stuff
Line 1531... Line 1434...
1531
                        
1434
                        
1532
                        ArrayList<PlannedPackage> usedBy = usedByPackages(pkg, results.planCollection);
1435
                        ArrayList<PlannedPackage> usedBy = usedByPackages(pkg, results.planCollection);
1533
                        toBuild.addAll(usedBy);
1436
                        toBuild.addAll(usedBy);
1534
                    }
1437
                    }
1535
                }
1438
                }
1536
                
1439
            }
1537
                //
1440
        }
1538
                //  Now we have a collection of packages to build ( and only the packages to build)
-
 
1539
                //  Need to determine the order in which it can be done and assign build levels
-
 
1540
                //  Basically:
1441
        else
1541
                //      Scan the collection looking for any package whose dependencies do not exist in the collection
-
 
1542
                //      or they have been allocated a build level.
-
 
1543
                //
1442
        {
1544
                //      Need to do this in waves so that we can correctly determine the build level.
-
 
1545
                //  
1443
            //  Escrow
1546
                //
1444
            //      Add all (not excluded) packages directly to the ripplePlan
1547
                for (Iterator<PlannedPackage> it = ripplePlan.iterator(); it.hasNext(); )
1445
            for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
1548
                {
1446
            {
1549
                    PlannedPackage p = it.next();
1447
                Package p = it.next();
1550
                    p.mPkg.mCheckedCircularDependency = true;
1448
                if (!p.mIsProcessed) {
1551
                    p.mBuildLevel = 0;
1449
                    ripplePlan.add(new PlannedPackage(p));
1552
                }
1450
                }
1553
                
1451
            }  
-
 
1452
        }
-
 
1453
            
-
 
1454
        //
-
 
1455
        //  Now we have a collection of packages to build (and only the packages to build)
-
 
1456
        //  Need to determine the order in which it can be done and assign build levels
-
 
1457
        //  Basically:
-
 
1458
        //      Scan the collection looking for any package whose dependencies do not exist in the collection
-
 
1459
        //      or they have been allocated a build level.
-
 
1460
        //
-
 
1461
        //      Need to do this in waves so that we can correctly determine the build level.
-
 
1462
        //  
-
 
1463
        //
-
 
1464
        for (Iterator<PlannedPackage> it = ripplePlan.iterator(); it.hasNext(); )
-
 
1465
        {
-
 
1466
            PlannedPackage p = it.next();
-
 
1467
            p.mPkg.mCheckedCircularDependency = true;
1554
                buildLevel = 0;
1468
            p.mBuildLevel = 0;
-
 
1469
        }
-
 
1470
        
-
 
1471
        int buildLevel = 0;
1555
                boolean more = true;
1472
        boolean more = true;
1556
                do  {
1473
        do  {
1557
                    ArrayList<PlannedPackage> thisLevel = new ArrayList<PlannedPackage>();
1474
            ArrayList<PlannedPackage> thisLevel = new ArrayList<PlannedPackage>();
1558
                    for (Iterator<PlannedPackage> it = ripplePlan.iterator(); it.hasNext(); )
1475
            for (Iterator<PlannedPackage> it = ripplePlan.iterator(); it.hasNext(); )
-
 
1476
            {
-
 
1477
                PlannedPackage p = it.next();
-
 
1478
                if ( p.mPkg.mCheckedCircularDependency )
-
 
1479
                {
-
 
1480
                    boolean found = false;
-
 
1481
                    for (Iterator<String> it2 = p.mPkg.mDependencyCollection.iterator(); !found && it2.hasNext(); )
1559
                    {
1482
                    {
1560
                        PlannedPackage p = it.next();
1483
                        String alias = it2.next();
1561
                        if ( p.mPkg.mCheckedCircularDependency )
1484
                        for (Iterator<PlannedPackage> it3 = ripplePlan.iterator(); !found && it3.hasNext(); )
1562
                        {
1485
                        {
1563
                            boolean found = false;
1486
                            PlannedPackage pkg = it3.next();
1564
                            for (Iterator<String> it2 = p.mPkg.mDependencyCollection.iterator(); !found && it2.hasNext(); )
1487
                            if (pkg.mPkg.mAlias.compareTo( alias ) == 0)
1565
                            {
1488
                            {
1566
                                String alias = it2.next();
-
 
1567
                                for (Iterator<PlannedPackage> it3 = ripplePlan.iterator(); !found && it3.hasNext(); )
-
 
1568
                                {
-
 
1569
                                    PlannedPackage pkg = it3.next();
-
 
1570
                                    if (pkg.mPkg.mAlias.compareTo( alias ) == 0)
-
 
1571
                                    {
-
 
1572
                                        found = pkg.mPkg.mCheckedCircularDependency ;
1489
                                found = pkg.mPkg.mCheckedCircularDependency ;
1573
                                        break;
-
 
1574
                                    }
1490
                                break;
1575
                                }
-
 
1576
                            }
-
 
1577
                            
-
 
1578
                            if (!found)
-
 
1579
                            {
-
 
1580
                                //  None of this packages dependencies can be found in the collection of packages to build
-
 
1581
                                //  Thus we can build it - at the current level
-
 
1582
                                p.mBuildLevel = buildLevel;
-
 
1583
                                thisLevel.add(p);
-
 
1584
                            }
1491
                            }
1585
                        }
1492
                        }
1586
                    }
1493
                    }
1587
                    
1494
                    
1588
                    //  Mark all the packages at this level as have been processed
-
 
1589
                    //  Cannot do this while we are determining the packages in the level 
-
 
1590
                    for (Iterator<PlannedPackage> it = thisLevel.iterator(); it.hasNext(); )
-
 
1591
                    {
-
 
1592
                        PlannedPackage p = it.next();
-
 
1593
                        p.mPkg.mCheckedCircularDependency = false;
-
 
1594
                    }
-
 
1595
                    
-
 
1596
                    more = !thisLevel.isEmpty(); 
-
 
1597
                    buildLevel++;
-
 
1598
                    
-
 
1599
                } while (more);
1495
                    if (!found)
1600
                
-
 
1601
                //  Sort the packages by buildOrder and buildTime
-
 
1602
                phase.setPhase("Sort Plan");
-
 
1603
                Collections.sort(ripplePlan, PlannedPackage.BuildOrderComparitor);
-
 
1604
                
-
 
1605
                if (mLogger.isInfoEnabled() )
-
 
1606
                {
-
 
1607
                    phase.setPhase("Display Build Order");
-
 
1608
                    mLogger.info("Plan Build {} Time: {}", name, results.planTime);
-
 
1609
                    for (Iterator<PlannedPackage> it = ripplePlan.iterator(); it.hasNext(); )
-
 
1610
                    {
1496
                    {
-
 
1497
                        //  None of this packages dependencies can be found in the collection of packages to build
1611
                        PlannedPackage p = it.next();
1498
                        //  Thus we can build it - at the current level
1612
                        mLogger.info("Plan: {} {} t:{}", p.mBuildLevel, p.mPkg.mAlias, p.mPkg.mBuildTime);
1499
                        p.mBuildLevel = buildLevel;
-
 
1500
                        thisLevel.add(p);
1613
                    }
1501
                    }
1614
                }
1502
                }
1615
            }
1503
            }
1616
            
1504
            
-
 
1505
            //  Mark all the packages at this level as have been processed
-
 
1506
            //  Cannot do this while we are determining the packages in the level 
-
 
1507
            for (Iterator<PlannedPackage> it = thisLevel.iterator(); it.hasNext(); )
-
 
1508
            {
-
 
1509
                PlannedPackage p = it.next();
1617
            //  Daemon mode: Returning calculated plan
1510
                p.mPkg.mCheckedCircularDependency = false;
-
 
1511
            }
-
 
1512
            
-
 
1513
            more = !thisLevel.isEmpty(); 
-
 
1514
            buildLevel++;
-
 
1515
            
-
 
1516
        } while (more);
-
 
1517
        
-
 
1518
        //  Sort the packages by buildOrder and buildTime
-
 
1519
        phase.setPhase("Sort Plan");
-
 
1520
        Collections.sort(ripplePlan, PlannedPackage.BuildOrderComparitor);
-
 
1521
        
-
 
1522
        if (mLogger.isInfoEnabled() )
-
 
1523
        {
-
 
1524
            phase.setPhase("Display Build Order");
-
 
1525
            mLogger.info("Plan Build {} Time: {}", name, results.planTime);
-
 
1526
            for (Iterator<PlannedPackage> it = ripplePlan.iterator(); it.hasNext(); )
-
 
1527
            {
1618
            results.planCollection = ripplePlan;
1528
                PlannedPackage p = it.next();
-
 
1529
                mLogger.info("Plan: {} {} t:{}", p.mBuildLevel, p.mPkg.mAlias, p.mPkg.mBuildTime);
-
 
1530
            }
1619
        }
1531
        }
-
 
1532
        
-
 
1533
        //  Daemon mode: Returning calculated plan
-
 
1534
        results.planCollection = ripplePlan;
1620
    
1535
    
1621
        phase.setPhase("EndPlanCollection");
1536
        phase.setPhase("EndPlanCollection");
1622
        return results;
1537
        return results;
1623
    }
1538
    }
1624
 
1539