Subversion Repositories DevTools

Rev

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

Rev 7088 Rev 7099
Line 828... Line 828...
828
                    mLogger.error("planRelease Test Build of an unbuildable of package deleted: {}", p.mName);
828
                    mLogger.error("planRelease Test Build of an unbuildable of package deleted: {}", p.mName);
829
                    mReleaseManager.markDaemonInstCompleted( p.mTestBuildInstruction );
829
                    mReleaseManager.markDaemonInstCompleted( p.mTestBuildInstruction );
830
                    emailRejectedDaemonInstruction(reason,p);
830
                    emailRejectedDaemonInstruction(reason,p);
831
                }
831
                }
832
            }
832
            }
833
            
-
 
834
            //  Daemon Mode Only
-
 
835
            //  Examine the build candidates and verify that a new version number can be calculated for each
-
 
836
            //  version that we need to build.
-
 
837
            //
-
 
838
            //  If we can't generate a new version number, then this is considered to be a build failure
-
 
839
            //  The package will be excluded and the user will be emailed
-
 
840
            //
-
 
841
            ArrayList<Package> testVersions = new ArrayList<Package>();
-
 
842
            testVersions.addAll(mPackageCollectionWip);
-
 
843
            testVersions.addAll(mPackageCollectionRipple);
-
 
844
            testVersions.addAll(mPackageCollectionTest);
-
 
845
            
-
 
846
            for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
-
 
847
            {
-
 
848
                Package p = it.next();
-
 
849
                if (p.mBuildFile >= 0 &&  p.mBuildReason != null) {
-
 
850
                    testVersions.add(p);
-
 
851
                }
-
 
852
            }
-
 
853
                    
-
 
854
            for (Iterator<Package> it = testVersions.iterator(); it.hasNext(); )
-
 
855
            {
-
 
856
                Package p = it.next();
-
 
857
 
-
 
858
                if ( p.mBuildFile >= 0 )
-
 
859
                {
-
 
860
                    int pvApplied = p.applyPV(mReleaseManager);
-
 
861
 
-
 
862
                    if ( pvApplied == 1 )
-
 
863
                    {
-
 
864
                        // max 50 chars
-
 
865
                        rippleBuildExclude(p, p.mId, "Package has non standard versioning", -5);
-
 
866
                    }
-
 
867
                    else if ( pvApplied == 2 )
-
 
868
                    {
-
 
869
                        // max 50 chars
-
 
870
                        rippleBuildExclude(p, p.mId, "Package has reached ripple field limitations", -5);
-
 
871
                    }
-
 
872
                    else if ( pvApplied == 3 )
-
 
873
                    {
-
 
874
                        // max 50 chars
-
 
875
                        rippleBuildExclude(p, p.mId, "Package has invalid change type", -5);
-
 
876
                    }
-
 
877
                }
-
 
878
            }
-
 
879
            
-
 
880
        }
833
        }
881
        else
834
        else
882
        {
835
        {
883
            // escrow reporting only
836
            // escrow reporting only
884
            // Report packages that are not reproducible
837
            // Report packages that are not reproducible
Line 906... Line 859...
906
         * @throws SQLException
859
         * @throws SQLException
907
         */
860
         */
908
        private void planBuildOrder() throws Exception, SQLException 
861
        private void planBuildOrder() throws Exception, SQLException 
909
        {
862
        {
910
            
863
            
911
    //TODO - Planning is not working well
-
 
912
    /**
864
    /**
913
     * Current status
865
     * Current status
914
     * The selection of the package to build next is deeply flawed
866
     *  basicPlan - time to complete current ripple
915
     * Currently it will select a directly planned package over a ripple - (perhaps that is good)
-
 
916
     * 
-
 
917
     * Currently on the buildPlan of the 'selected' package is included in the BuildOrder
867
     *  FullPlan - Include all WIPS/RIPPLES into the release set
918
     * 
868
     *  
919
     * The current algorithm is based on time - but all packages have zero build time ( in UTF )
869
     *  If the full Plan does NOT extend the time of the basicPLan by 20% then use the full plan
920
     * Even if this is fixed the algorithm is broken as we will select the complete build with the shortest time
-
 
921
     * which will be the ripple of a leaf package ( perhaps that is good )
870
     *  otherwise complete the current ripple and the include WIPs/RIPPLEs\
922
     * 
-
 
923
     * Also:
-
 
924
     *      [Done] Need to include all packages that we can now build into the final build plan, not just the first one and its build tree
-
 
925
     * 
871
     *  
926
     *      [Done-ish]Need to generate a single package set - so that WIPS and others replace those in the final build set
-
 
927
     *      [Done]Remove duplicates from the complete package set
-
 
928
     *      
-
 
929
     *      [Being Done] Need more test cases
872
     *  TEST requests will be done first.
930
     *      
-
 
931
     *      [Done, in the UTF] Need to report all build options, not just the selected one
-
 
932
     *                         Data to RM may need some more info
-
 
933
     *      
-
 
934
     *      Cleanup the ANT build file - don't list all the release dependencies, just those needed to build the current package
-
 
935
     *      Chances are - all we need is the new package version number
-
 
936
     *      
873
     *
937
     *      [Fixed] If a WIP on a package that has circular dependencies is added, then the WIP will be excluded. This prevents the problem being fixed.
-
 
938
     *              Should not exclude a WIP of a package with a circular dependency
-
 
939
     */
874
     */
940
    
875
    
941
            // Process remaining packages which are need to be reproduced for this baseline.
876
            // Process remaining packages which are need to be reproduced for this baseline.
942
            //    Determine the build file for each package
877
            //    Determine the build file for each package
943
            //    For daemon builds:
878
            //    For daemon builds:
Line 1006... Line 941...
1006
                //  Otherwise we use basic plan FOLLOWED by the a MODIFIED full plan (one without the natural ripples)
941
                //  Otherwise we use basic plan FOLLOWED by the a MODIFIED full plan (one without the natural ripples)
1007
                //  Add the planned packages into the buildOrder
942
                //  Add the planned packages into the buildOrder
1008
    
943
    
1009
                if( !basicPlan.planCollection.isEmpty() && !fullPlan.planCollection.isEmpty() )
944
                if( !basicPlan.planCollection.isEmpty() && !fullPlan.planCollection.isEmpty() )
1010
                {
945
                {
1011
                    mLogger.info("Two plan selection: {} {}, {} <= {}", basicPlan.planTime,fullPlan.planTime, basicPlan.planTime * 12, fullPlan.planTime * 10);
946
                    mLogger.error("Two plan selection: {} {}, {} <= {}", basicPlan.planTime,fullPlan.planTime, basicPlan.planTime * 12, fullPlan.planTime * 10);
-
 
947
                    
-
 
948
                    //
-
 
949
                    //  Report numbers for Bryan - can be removed after Aug-2019
-
 
950
                    //  See PX-14283
-
 
951
                    //
-
 
952
                    {
-
 
953
                        String BI = "--";
-
 
954
                        String BE = "--";
-
 
955
                        if (fullPlan.planTime != basicPlan.planTime &&  basicPlan.planTime  != 0) {
-
 
956
                            BI = Float.toString( (fullPlan.planTime - basicPlan.planTime) / (float)basicPlan.planTime);
-
 
957
                            BE = Float.toString( (float)fullPlan.planTime  / (fullPlan.planTime - basicPlan.planTime));
-
 
958
                        }
-
 
959
                        mLogger.error("PLAN STATS: Estimated time to complete current plan (ETC): {}", basicPlan.planTime);
-
 
960
                        mLogger.error("PLAN STATS: Estimated time to full plan (PBT): {}", fullPlan.planTime);
-
 
961
                        mLogger.error("PLAN STATS: Build Impact (BI): {}", BI);
-
 
962
                        mLogger.error("PLAN STATS: Build Efficiency (BE): {}", BE);
-
 
963
                    }
-
 
964
                    
-
 
965
                    
1012
                    if ( (basicPlan.planTime * 12) <= (fullPlan.planTime * 10) )
966
                    if ( (basicPlan.planTime * 12) <= (fullPlan.planTime * 10) )
1013
                    {
967
                    {
1014
                        //  Use the basic plan FOLLOWED by a plan that does not include
968
                        //  Use the basic plan FOLLOWED by a plan that does not include
1015
                        //      Ripples done by the basic plan
969
                        //      Ripples done by the basic plan
1016
                        //      WIPs/RIPPLES done in the course of doing the basic plan
970
                        //      WIPs/RIPPLES done in the course of doing the basic plan
1017
    
-
 
-
 
971
                        mLogger.error("Use basic plan, then modified full plan");
1018
                        mBuildOrder.addAll(basicPlan.planCollection);
972
                        mBuildOrder.addAll(basicPlan.planCollection);
1019
                        fullPlan = postRipplePlan("Full-Ripples", basicPlan, false);
973
                        fullPlan = postRipplePlan("Full-Ripples", basicPlan, false);
1020
                        mBuildOrder.addAll(fullPlan.planCollection);
974
                        mBuildOrder.addAll(fullPlan.planCollection);
1021
                        
975
                        
1022
                    } else {
976
                    } else {
1023
                        //  Use the full plan
977
                        //  Use the full plan
-
 
978
                        mLogger.error("Use full plan");
1024
                        mBuildOrder.addAll(fullPlan.planCollection);
979
                        mBuildOrder.addAll(fullPlan.planCollection);
1025
                    }
980
                    }
1026
                } else if (!basicPlan.planCollection.isEmpty() ) {
981
                } else if (!basicPlan.planCollection.isEmpty() ) {
1027
                    // Use the basic plan
982
                    // Use the basic plan
-
 
983
                    mLogger.error("Use basic plan");
1028
                    mBuildOrder.addAll(basicPlan.planCollection);
984
                    mBuildOrder.addAll(basicPlan.planCollection);
1029
                    
985
                    
1030
                } else if ( !fullPlan.planCollection.isEmpty() ) {
986
                } else if ( !fullPlan.planCollection.isEmpty() ) {
1031
                    // Use the full plan
987
                    // Use the full plan
-
 
988
                    mLogger.error("Use full plan");
1032
                    mBuildOrder.addAll(fullPlan.planCollection);
989
                    mBuildOrder.addAll(fullPlan.planCollection);
1033
                    
990
                    
1034
                } else {
991
                } else {
1035
                    // Do not have a plan
992
                    // Do not have a plan
1036
                    // May have tests requests
993
                    // May have tests requests
-
 
994
                    mLogger.error("Use NO plan");
1037
                }
995
                }
1038
                
996
                
1039
                //  Now have an mBuildOrder
-
 
1040
                //  Mark the first package in the build order as the one to be built
-
 
1041
                //
997
                //
-
 
998
                //  Now have a build order
-
 
999
                //  Allocate new version numbers
-
 
1000
                //      Examine packages with a buidLevel of zero
-
 
1001
                //  If we fail all of them then we can't build anything
-
 
1002
                //
-
 
1003
                mLogger.error("Determine new version numbers");
1042
                Package build = ReleaseManager.NULL_PACKAGE;
1004
                Package build = ReleaseManager.NULL_PACKAGE;
-
 
1005
                for (Iterator<PlannedPackage> it = mBuildOrder.iterator(); it.hasNext(); )
-
 
1006
                {
-
 
1007
                    PlannedPackage pkg = it.next();
-
 
1008
                    if (pkg.mBuildLevel != 0)
-
 
1009
                    {
-
 
1010
                        continue;
-
 
1011
                    }
-
 
1012
                    
-
 
1013
                    //
-
 
1014
                    //  Attempt to allocate a new version number
-
 
1015
                    //  If we can't generate a new version number, then this is considered to be a build failure
-
 
1016
                    //  The package will be excluded and the user will be emailed
-
 
1017
                    //
-
 
1018
 
-
 
1019
 
-
 
1020
                    Package p = pkg.mPkg;
-
 
1021
 
-
 
1022
                    int pvApplied = p.applyPV(mReleaseManager);
-
 
1023
 
-
 
1024
                    if ( pvApplied == 0)
-
 
1025
                    {
-
 
1026
                        build = p;
-
 
1027
                        break;
-
 
1028
                    }
-
 
1029
                    else if ( pvApplied == 1 )
-
 
1030
                    {
-
 
1031
                        // max 50 chars
-
 
1032
                        rippleBuildExclude(p, p.mId, "Package has non standard versioning", -12);
-
 
1033
                    }
-
 
1034
                    else if ( pvApplied == 2 )
-
 
1035
                    {
-
 
1036
                        // max 50 chars
-
 
1037
                        rippleBuildExclude(p, p.mId, "Package has reached ripple field limitations", -12);
-
 
1038
                    }
-
 
1039
                    else if ( pvApplied == 3 )
-
 
1040
                    {
-
 
1041
                        // max 50 chars
-
 
1042
                        rippleBuildExclude(p, p.mId, "Package has invalid change type", -12);
-
 
1043
                    }
-
 
1044
                    else
-
 
1045
                    {
-
 
1046
                        // max 50 chars
-
 
1047
                        // Bad programming - should not get here
-
 
1048
                        rippleBuildExclude(p, p.mId, "Unable to calculate next version", -12);
-
 
1049
                    }
-
 
1050
                }
-
 
1051
                
-
 
1052
                
-
 
1053
                //  Now have an mBuildOrder
-
 
1054
                //  Mark the selected package in the build order as the one to be built
-
 
1055
                //  May need to process its it a bit more
-
 
1056
                //  
1043
                if (!mBuildOrder.isEmpty()) {
1057
                if (!mBuildOrder.isEmpty()) {
1044
                    build = mBuildOrder.get(0).mPkg;
-
 
1045
                    build.mBuildFile = 1;
1058
                    build.mBuildFile = 1;
1046
                    
1059
                    
1047
                    if ( build.mForcedRippleInstruction > 0 )
1060
                    if ( build.mForcedRippleInstruction > 0 )
1048
                    {
1061
                    {
1049
                        mReleaseManager.markDaemonInstCompleted( build.mForcedRippleInstruction );
1062
                        mReleaseManager.markDaemonInstCompleted( build.mForcedRippleInstruction );
Line 1056... Line 1069...
1056
                    
1069
                    
1057
                    //  Now that we know which package we are building
1070
                    //  Now that we know which package we are building
1058
                    //      Set the previously calculated nextVersion as the packages version number
1071
                    //      Set the previously calculated nextVersion as the packages version number
1059
                    //      Claim the version number to prevent other builds from using it. Even if doing a test build
1072
                    //      Claim the version number to prevent other builds from using it. Even if doing a test build
1060
                    //
1073
                    //
-
 
1074
                    mLogger.error("Update mVersion: {}", build);
1061
                    if (build.mNextVersion != null)
1075
                    if (build.mNextVersion != null)
1062
                    {
1076
                    {
1063
                        mReleaseManager.claimVersion(build.mPid, build.mNextVersion + build.mExtension, mBaseline);
1077
                        mReleaseManager.claimVersion(build.mPid, build.mNextVersion + build.mExtension, mBaseline);
1064
                        build.mVersion = build.mNextVersion;
1078
                        build.mVersion = build.mNextVersion;
-
 
1079
                        mLogger.error("Update mVersion: {} to {}", build, build.mVersion);
1065
                    }
1080
                    }
1066
                }
1081
                }
1067
                
1082
                
1068
                //
1083
                //
1069
                //  Massage the package collection
1084
                //  Massage the package collection
Line 1156... Line 1171...
1156
                                 
1171
                                 
1157
                                 if (!found)
1172
                                 if (!found)
1158
                                 {
1173
                                 {
1159
                                     BuildExclusion buildExclusion = new BuildExclusion(pkg.mId, p.mId, null, p.mTestBuildInstruction);
1174
                                     BuildExclusion buildExclusion = new BuildExclusion(pkg.mId, p.mId, null, p.mTestBuildInstruction);
1160
                                     it.add(buildExclusion);
1175
                                     it.add(buildExclusion);
1161
                                     mLogger.info("Indirectly Excluded Package {}", pkg.mAlias);  
1176
                                     mLogger.info("Indirectly Excluded Package {}", pkg.mAlias);
-
 
1177
                                     pkg.mBuildFile = -5; 
1162
 
1178
 
1163
                                     ArrayList<Package> usedBy = usedByAnyPackages(p, mPackageCollectionAll );
1179
                                     ArrayList<Package> usedBy = usedByAnyPackages(pkg, mPackageCollectionAll );
1164
                                     toExclude.addAll(usedBy);
1180
                                     toExclude.addAll(usedBy);
1165
                                 }
1181
                                 }
1166
                             }
1182
                             }
1167
                         }
1183
                         }
1168
                     }
1184
                     }
1169
                 }
1185
                 }
-
 
1186
                 
-
 
1187
                 //
-
 
1188
                 //  Examine the build order and 'delete' entries with a -ve mBuildFile
-
 
1189
                 //  These will be the product of pvApply errors and the packages that depend on them
-
 
1190
                 
-
 
1191
                 for (Iterator<PlannedPackage> it = mBuildOrder.iterator(); it.hasNext(); )
-
 
1192
                 {
-
 
1193
                     PlannedPackage pkg = it.next();
-
 
1194
                     if (pkg.mPkg.mBuildFile < 0)
-
 
1195
                     {
-
 
1196
                         it.remove();
-
 
1197
                         mLogger.error("Purge mBuildOrder {}", pkg.mPkg);
-
 
1198
                     }
-
 
1199
                 }
-
 
1200
                 
-
 
1201
 
1170
                
1202
                
1171
                //
1203
                //
1172
                //  To fit in with the old algorithm ( ie: could be improved )
1204
                //  To fit in with the old algorithm ( ie: could be improved )
1173
                //  Insert marks into all packages
1205
                //  Insert marks into all packages
1174
                //  Not sure exactly why - Its used in the generation of the ant build file
1206
                //  Not sure exactly why - Its used in the generation of the ant build file
Line 1245... Line 1277...
1245
     * 
1277
     * 
1246
     * @return
1278
     * @return
1247
     */
1279
     */
1248
    private PlanResults planCollection(String name, ArrayList<Package> packageCollection, boolean mode)
1280
    private PlanResults planCollection(String name, ArrayList<Package> packageCollection, boolean mode)
1249
    {
1281
    {
-
 
1282
        Phase phase = new Phase("PlanCollection"); 
1250
        ArrayList<PlannedPackage> ripplePlan = new ArrayList<PlannedPackage>();
1283
        ArrayList<PlannedPackage> ripplePlan = new ArrayList<PlannedPackage>();
1251
        PlanResults results = new PlanResults();
1284
        PlanResults results = new PlanResults();
1252
 
1285
 
1253
        //  Reset flags used in the calculations
1286
        //  Reset flags used in the calculations
1254
        Package.resetProcessed(packageCollection);
1287
        Package.resetProcessed(packageCollection);
1255
        
1288
        
1256
        //  Exclude all packages that cannot be built and all packages that depend on them
1289
        //  Exclude all packages that cannot be built and all packages that depend on them
1257
        //      First find packages to be directly excluded
1290
        //      First find packages to be directly excluded
1258
        ArrayList<Package>exclude = new ArrayList<Package>();
1291
        ArrayList<Package>exclude = new ArrayList<Package>();
-
 
1292
        phase.setPhase("Exclude Unbuildable");
1259
        for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
1293
        for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
1260
        {
1294
        {
1261
            Package p = it.next();
1295
            Package p = it.next();
1262
            if ( p.mBuildFile == -8 ) {
1296
            if ( p.mBuildFile == -8 ) {
1263
 
1297
 
Line 1273... Line 1307...
1273
            }
1307
            }
1274
        }
1308
        }
1275
        
1309
        
1276
        //  Exclude packages that have failed to be built
1310
        //  Exclude packages that have failed to be built
1277
        //      These are recorded in mBuildExclusionCollection
1311
        //      These are recorded in mBuildExclusionCollection
-
 
1312
        phase.setPhase("Exclude Build Failures");
1278
        for (ListIterator<BuildExclusion> it = mBuildExclusionCollection.listIterator(); it.hasNext(); )
1313
        for (ListIterator<BuildExclusion> it = mBuildExclusionCollection.listIterator(); it.hasNext(); )
1279
        {
1314
        {
1280
            BuildExclusion be = it.next();
1315
            BuildExclusion be = it.next();
-
 
1316
            mLogger.error("BE: {}", be);
1281
            if ( be.isABuildError() )
1317
            if ( !be.isAIndirectError() )
1282
            {
1318
            {
1283
                for (Iterator<Package> it1 = packageCollection.iterator(); it1.hasNext(); )
1319
                for (Iterator<Package> it1 = packageCollection.iterator(); it1.hasNext(); )
1284
                {
1320
                {
1285
                    Package p = it1.next();
1321
                    Package p = it1.next();
1286
                    if (p.mBuildFile >= 0 && p.mId == be.mId) {
1322
                    if (p.mBuildFile >= 0 && p.mId == be.mId) {
1287
                        p.mBuildFile  = -3;
1323
                        p.mBuildFile  = -3;
-
 
1324
                        mLogger.error("AddExclude {}",p);
1288
                        exclude.add(p);
1325
                        exclude.add(p);
1289
                        break;
1326
                        break;
1290
                    }
1327
                    }
1291
                }
1328
                }
1292
            }
1329
            }
1293
        }
1330
        }
1294
 
1331
 
1295
        
1332
        
1296
        //  Process the list of packages to be excluded
1333
        //  Process the list of packages to be excluded
1297
        //  Add to the list packages that depend on the excluded package that have not already been excluded
1334
        //  Add to the list packages that depend on the excluded package that have not already been excluded
-
 
1335
        phase.setPhase("ExcludeAllUsed");
1298
        while( !exclude.isEmpty() )
1336
        while( !exclude.isEmpty() )
1299
        {
1337
        {
1300
            Package p = exclude.remove(0);
1338
            Package p = exclude.remove(0);
1301
            p.mProcessed = true;
1339
            p.mProcessed = true;
1302
            p.mIsProcessed = true;
1340
            p.mIsProcessed = true;
Line 1323... Line 1361...
1323
        //  Process the list and determine packages that we can build right now
1361
        //  Process the list and determine packages that we can build right now
1324
        //      ie: they have not been excluded, have not already been discovered and do not depend on any package in the collection
1362
        //      ie: they have not been excluded, have not already been discovered and do not depend on any package in the collection
1325
        //      Continue to do this until all packages have been extracted
1363
        //      Continue to do this until all packages have been extracted
1326
        //      Allocate build levels as we go
1364
        //      Allocate build levels as we go
1327
        //
1365
        //
-
 
1366
        phase.setPhase("Determine Build Order");
1328
        boolean allProcessed = false;
1367
        boolean allProcessed = false;
1329
        int buildLevel = 1;
1368
        int buildLevel = 1;
1330
 
1369
 
1331
        do
1370
        do
1332
        {
1371
        {
Line 1401... Line 1440...
1401
                        }
1440
                        }
1402
                    }
1441
                    }
1403
                }
1442
                }
1404
            } while( !allDependenciesProcessed );
1443
            } while( !allDependenciesProcessed );
1405
            
1444
            
1406
            //  Have process all the packages that we can at the moment
1445
            //  Have process all the packages that we can build at the moment
1407
            //      Examine all the packages in the collection to see if there are more that need to be extracted
1446
            //      Examine all the packages in the collection to see if there are more that need to be extracted
1408
            //      These will be done at a different build-level
1447
            //      These will be done at a different build-level
1409
            //  
1448
            //  
1410
            allProcessed = true;
1449
            allProcessed = true;
1411
            for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
1450
            for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
Line 1429... Line 1468...
1429
        //  Now we have a collection packages that we can build right now
1468
        //  Now we have a collection packages that we can build right now
1430
        //      The packages currently have a build level set into mBuildFile
1469
        //      The packages currently have a build level set into mBuildFile
1431
        //
1470
        //
1432
        if (mDaemon)
1471
        if (mDaemon)
1433
        {
1472
        {
1434
            //  Determine if we have a reason to build anything in this collection of buildable packages
-
 
1435
            //  Reset the calculated buildLevel - It will be calculated again
1473
            phase.setPhase("Calc Build Order");
1436
            //
1474
            //
-
 
1475
            //  Determine if we have a reason to build anything in this collection of buildable packages
-
 
1476
            //      Reset the calculated buildLevel - It will be calculated again
-
 
1477
            //      Reset the mProcessed - it will be used to detect  that we have processed a package
-
 
1478
            
1437
            ArrayList<PlannedPackage> toBuild = new ArrayList<PlannedPackage>();
1479
            ArrayList<PlannedPackage> toBuild = new ArrayList<PlannedPackage>();
1438
            for (Iterator<PlannedPackage> it = results.planCollection.iterator(); it.hasNext(); )
1480
            for (Iterator<PlannedPackage> it = results.planCollection.iterator(); it.hasNext(); )
1439
            {
1481
            {
1440
                PlannedPackage p = it.next();
1482
                PlannedPackage p = it.next();
1441
                p.mBuildLevel = 0;
1483
                p.mBuildLevel = 0;
-
 
1484
                p.mPkg.mCheckedCircularDependency = false;
1442
                
1485
                
1443
                if (p.mPkg.mBuildReason != null) {
1486
                if (p.mPkg.mBuildReason != null) {
1444
                    if (mode || ( !mode && p.mPkg.mBuildReason != BuildReason.Ripple ))
1487
                    if (mode || ( !mode && p.mPkg.mBuildReason != BuildReason.Ripple ))
1445
                    {
1488
                    {
1446
                        toBuild.add(p);
1489
                        toBuild.add(p);
Line 1451... Line 1494...
1451
            //  Need (would like to) build stuff
1494
            //  Need (would like to) build stuff
1452
            //  Determine the packages that we need to build and the time that it will take
1495
            //  Determine the packages that we need to build and the time that it will take
1453
            //
1496
            //
1454
            if ( !toBuild.isEmpty() )
1497
            if ( !toBuild.isEmpty() )
1455
            {
1498
            {
1456
                results.planTime = 0;
1499
                //  Locate the packages that we need to build
1457
                             
1500
                //  The build order cannot be correctly determined at this time
1458
                
-
 
1459
                //  Need to add elements to the end of the list while processing
1501
                //      Need to add elements to the end of the list while processing
1460
                //  Sum the buildTimes of the packages that we add to the list
1502
                //      Sum the buildTimes of the packages that we add to the list
1461
                while ( ! toBuild.isEmpty())
1503
                while ( ! toBuild.isEmpty())
1462
                {
1504
                {
1463
                    PlannedPackage pkg = toBuild.remove(0);
1505
                    PlannedPackage pkg = toBuild.remove(0);
1464
                    
1506
                    
1465
                    if (pkg.mBuildLevel > 100 ) {
1507
                    if (pkg.mBuildLevel > 400 ) {
1466
                        mLogger.error("Circular dependency detected - not handled well");
1508
                        mLogger.error("Circular dependency detected - not handled well");
1467
                        break;
1509
                        break;
1468
                    }
1510
                    }
1469
                    
1511
                    
1470
                    if ( ! ripplePlan.contains( pkg ))
1512
                    if ( ! pkg.mPkg.mCheckedCircularDependency )
1471
                    {
1513
                    {
1472
                        ripplePlan.add(pkg);
1514
                        ripplePlan.add(pkg);
1473
                        results.planTime += pkg.mPkg.mBuildTime;
1515
                        results.planTime += pkg.mPkg.mBuildTime;
-
 
1516
                        pkg.mPkg.mCheckedCircularDependency = true;
-
 
1517
                        
-
 
1518
                        ArrayList<PlannedPackage> usedBy = usedByPackages(pkg, results.planCollection);
-
 
1519
                        toBuild.addAll(usedBy);
1474
                    }
1520
                    }
1475
                    
-
 
1476
                    ArrayList<PlannedPackage> usedBy = usedByPackages(pkg, results.planCollection, pkg.mBuildLevel + 1);
-
 
1477
                    toBuild.addAll(usedBy);
-
 
1478
                }
1521
                }
1479
                
1522
                
-
 
1523
                //
-
 
1524
                //  Now we have a collection of packages to build ( and only the packages to build)
-
 
1525
                //  Need to determine the order in which it can be done and assign build levels
-
 
1526
                //  Basically:
-
 
1527
                //      Scan the collection looking for any package whose dependencies do not exist in the collection
-
 
1528
                //      or they have been allocated a build level.
-
 
1529
                //
-
 
1530
                //      Need to do this in waves so that we can correctly determine the build level.
-
 
1531
                //  
-
 
1532
                //
-
 
1533
                for (Iterator<PlannedPackage> it = ripplePlan.iterator(); it.hasNext(); )
-
 
1534
                {
-
 
1535
                    PlannedPackage p = it.next();
-
 
1536
                    p.mPkg.mCheckedCircularDependency = true;
-
 
1537
                    p.mBuildLevel = 0;
-
 
1538
                }
-
 
1539
                
-
 
1540
                buildLevel = 0;
-
 
1541
                boolean more = true;
-
 
1542
                do  {
-
 
1543
                    ArrayList<PlannedPackage> thisLevel = new ArrayList<PlannedPackage>();
-
 
1544
                    for (Iterator<PlannedPackage> it = ripplePlan.iterator(); it.hasNext(); )
-
 
1545
                    {
-
 
1546
                        PlannedPackage p = it.next();
-
 
1547
                        if ( p.mPkg.mCheckedCircularDependency )
-
 
1548
                        {
-
 
1549
                            boolean found = false;
-
 
1550
                            for (Iterator<String> it2 = p.mPkg.mDependencyCollection.iterator(); !found && it2.hasNext(); )
-
 
1551
                            {
-
 
1552
                                String alias = it2.next();
-
 
1553
                                for (Iterator<PlannedPackage> it3 = ripplePlan.iterator(); !found && it3.hasNext(); )
-
 
1554
                                {
-
 
1555
                                    PlannedPackage pkg = it3.next();
-
 
1556
                                    if (pkg.mPkg.mAlias.compareTo( alias ) == 0)
-
 
1557
                                    {
-
 
1558
                                        found = pkg.mPkg.mCheckedCircularDependency ;
-
 
1559
                                        break;
-
 
1560
                                    }
-
 
1561
                                }
-
 
1562
                            }
-
 
1563
                            
-
 
1564
                            if (!found)
-
 
1565
                            {
-
 
1566
                                //  None of this packages dependencies can be found in the collection of packages to build
-
 
1567
                                //  Thus we can build it - at the current level
-
 
1568
                                p.mBuildLevel = buildLevel;
-
 
1569
                                thisLevel.add(p);
-
 
1570
                            }
-
 
1571
                        }
-
 
1572
                    }
-
 
1573
                    
-
 
1574
                    //  Mark all the packages at this level as have been processed
-
 
1575
                    //  Cannot do this while we are determining the packages in the level 
-
 
1576
                    for (Iterator<PlannedPackage> it = thisLevel.iterator(); it.hasNext(); )
-
 
1577
                    {
-
 
1578
                        PlannedPackage p = it.next();
-
 
1579
                        p.mPkg.mCheckedCircularDependency = false;
-
 
1580
                    }
-
 
1581
                    
-
 
1582
                    more = !thisLevel.isEmpty(); 
-
 
1583
                    buildLevel++;
-
 
1584
                    
-
 
1585
                } while (more);
-
 
1586
                
1480
                //  Sort the packages by buildOrder and buildTime
1587
                //  Sort the packages by buildOrder and buildTime
-
 
1588
                phase.setPhase("Sort Plan");
1481
                Collections.sort(ripplePlan, PlannedPackage.BuildOrderComparitor);
1589
                Collections.sort(ripplePlan, PlannedPackage.BuildOrderComparitor);
1482
                
1590
                
-
 
1591
                phase.setPhase("Display Build Order");
1483
                mLogger.info("Plan Build {} Time: {}", name, results.planTime);
1592
                mLogger.error("Plan Build {} Time: {}", name, results.planTime);
1484
                for (Iterator<PlannedPackage> it = ripplePlan.iterator(); it.hasNext(); )
1593
                for (Iterator<PlannedPackage> it = ripplePlan.iterator(); it.hasNext(); )
1485
                {
1594
                {
1486
                    PlannedPackage p = it.next();
1595
                    PlannedPackage p = it.next();
1487
                    mLogger.info("Plan: {} {}", p.mBuildLevel, p.mPkg.mAlias);
1596
                    mLogger.error("Plan: {} {} t:{}", p.mBuildLevel, p.mPkg.mAlias, p.mPkg.mBuildTime);
1488
                }
1597
                }
1489
            }
1598
            }
1490
            
1599
            
1491
            //  Daemon mode: Returning calculated plan
1600
            //  Daemon mode: Returning calculated plan
1492
            results.planCollection = ripplePlan;
1601
            results.planCollection = ripplePlan;
1493
        }
1602
        }
1494
        
1603
    
-
 
1604
        phase.setPhase("EndPlanCollection");
1495
        return results;
1605
        return results;
1496
    }
1606
    }
1497
 
1607
 
1498
    /** Generate a plan based on a modified set of packages
1608
    /** Generate a plan based on a modified set of packages
1499
     * 
1609
     * 
Line 1523... Line 1633...
1523
                        for (Iterator<PlannedPackage> it1 = basicPlan.planCollection.iterator(); it1.hasNext(); )
1633
                        for (Iterator<PlannedPackage> it1 = basicPlan.planCollection.iterator(); it1.hasNext(); )
1524
                        {
1634
                        {
1525
                            PlannedPackage pkg = it1.next();
1635
                            PlannedPackage pkg = it1.next();
1526
                            if (pkg.mPkg == p)
1636
                            if (pkg.mPkg == p)
1527
                            {
1637
                            {
1528
                                mLogger.info("Test Plan without {}", p.mAlias);
1638
                                mLogger.error("Test Plan without {}", p.mAlias);
1529
                                continue;
1639
                                continue;
1530
                            }
1640
                            }
1531
                        }
1641
                        }
1532
                    }
1642
                    }
1533
                    
1643
                    
1534
                    mLogger.info("Test Plan with {}", p.mAlias);
1644
                    mLogger.error("Test Plan with {}", p.mAlias);
1535
                    Package foundInRelease = mReleaseManager.findPackage(p.mAlias, fullPlanCollection);
1645
                    Package foundInRelease = mReleaseManager.findPackage(p.mAlias, fullPlanCollection);
1536
                    int foundIndex = mReleaseManager.findPackageLastIndex;
1646
                    int foundIndex = mReleaseManager.findPackageLastIndex;
1537
                    if (foundInRelease == ReleaseManager.NULL_PACKAGE)
1647
                    if (foundInRelease == ReleaseManager.NULL_PACKAGE)
1538
                    {
1648
                    {
1539
                        fullPlanCollection.add(p);
1649
                        fullPlanCollection.add(p);
Line 1569... Line 1679...
1569
     *      If the consumer is marked as advisoryRipple
1679
     *      If the consumer is marked as advisoryRipple
1570
     *      If the consumer cannot be built
1680
     *      If the consumer cannot be built
1571
     *   
1681
     *   
1572
     * @param pkg - Package to process
1682
     * @param pkg - Package to process
1573
     * @param planCollection - collection of packages to scan
1683
     * @param planCollection - collection of packages to scan
1574
     * @param rippleOrder - Set the ripple oder, if >= 0
-
 
1575
     *
1684
     *
1576
     * @return A collection of packages that actively 'use' the specified package
1685
     * @return A collection of packages that actively 'use' the specified package
1577
 
1686
 
1578
     */
1687
     */
1579
    private ArrayList<PlannedPackage> usedByPackages(PlannedPackage pkg, ArrayList<PlannedPackage> planCollection, int rippleOrder) {
1688
    private ArrayList<PlannedPackage> usedByPackages(PlannedPackage pkg, ArrayList<PlannedPackage> planCollection) {
1580
        
1689
        
1581
        ArrayList<PlannedPackage> usedBy = new ArrayList<PlannedPackage>();
1690
        ArrayList<PlannedPackage> usedBy = new ArrayList<PlannedPackage>();
1582
        
1691
        
1583
        for (Iterator<PlannedPackage> it = planCollection.iterator(); it.hasNext(); )
1692
        for (Iterator<PlannedPackage> it = planCollection.iterator(); it.hasNext(); )
1584
        {
1693
        {
Line 1591... Line 1700...
1591
                {
1700
                {
1592
                    String alias = it2.next();
1701
                    String alias = it2.next();
1593
                    if (  pkg.mPkg.mAlias.compareTo( alias ) == 0  ) {
1702
                    if (  pkg.mPkg.mAlias.compareTo( alias ) == 0  ) {
1594
                        //  Have found a consumer of 'pkg'
1703
                        //  Have found a consumer of 'pkg'
1595
                        usedBy.add(p);
1704
                        usedBy.add(p);
1596
                        if (rippleOrder >= 0)
-
 
1597
                            p.mBuildLevel = rippleOrder;
-
 
1598
                        break;
1705
                        break;
1599
                    }
1706
                    }
1600
                }
1707
                }
1601
            }
1708
            }
1602
        }
1709
        }
Line 1833... Line 1940...
1833
     */
1940
     */
1834
    private void rippleBuildExclude(Package p, int rootPvId, String rootCause, int reason )
1941
    private void rippleBuildExclude(Package p, int rootPvId, String rootCause, int reason )
1835
    {
1942
    {
1836
        mLogger.debug("rippleBuildExclude");
1943
        mLogger.debug("rippleBuildExclude");
1837
     
1944
     
1838
        if ( p.mBuildFile == 0 || p.mBuildFile == 1 )
1945
        if ( p.mBuildFile >= 0 )
1839
        {
1946
        {
1840
            p.mBuildFile = reason;
1947
            p.mBuildFile = reason;
1841
            mLogger.info("rippleBuildExclude set mBuildFile to -5 for package {}", p.mAlias );
1948
            mLogger.info("rippleBuildExclude set mBuildFile to {} for package {}", reason, p.mAlias );
1842
            
1949
            
1843
            //  Scan the complete collection looking for a matching item
1950
            //  Scan the complete collection looking for a matching item
1844
            //  If found then assume that this error is a a PlanError that is still present
1951
            //  If found then assume that this error is a a PlanError that is still present
1845
            //      Mark it as Processed to indicate that its still present
1952
            //      Mark it as Processed to indicate that its still present
1846
            //  If found, process it, else add it (unprocessed)
1953
            //  If found, process it, else add it (unprocessed)