From: <mar...@us...> - 2008-03-10 00:09:56
|
Revision: 143 http://gridsim.svn.sourceforge.net/gridsim/?rev=143&view=rev Author: marcos_dias Date: 2008-03-09 17:10:00 -0700 (Sun, 09 Mar 2008) Log Message: ----------- Some methods have been moved from the allocation policies to TAllocPolicy. Modified Paths: -------------- branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java 2008-03-09 02:56:01 UTC (rev 142) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java 2008-03-10 00:10:00 UTC (rev 143) @@ -539,20 +539,6 @@ } /** - * Updates the Gridlet's properties, such as status once a - * Gridlet is considered finished. - * @param sgl a SSGridlet object - * @param status the Gridlet status - */ - protected void gridletFinish(SSGridlet sgl, int status) { - // the order is important! Set the status first then finalise - // due to timing issues in SSGridlet class - sgl.setStatus(status); - sgl.finalizeGridlet(); - super.sendFinishGridlet( sgl.getGridlet() ); - } - - /** * This method removes/updates all the entries of a gridlet from the profile * and updates the ranges of current free PEs if the gridlet was in execution. * @param gridlet the Gridlet to be removed Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java 2008-03-09 02:56:01 UTC (rev 142) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java 2008-03-10 00:10:00 UTC (rev 143) @@ -1169,20 +1169,6 @@ } /** - * Updates the Gridlet's properties, such as status once a - * Gridlet is considered finished. - * @param sgl a SSGridlet object - * @param status the Gridlet status - */ - private void gridletFinish(SSGridlet sgl, int status) { - // the order is important! Set the status first then finalise - // due to timing issues in SSGridlet class - sgl.setStatus(status); - sgl.finalizeGridlet(); - super.sendFinishGridlet( sgl.getGridlet() ); - } - - /** * This method removes/updates all the entries of a gridlet from the profile * and updates the ranges of current free PEs if the gridlet was in execution. * @param gridlet the Gridlet to be removed Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java 2008-03-09 02:56:01 UTC (rev 142) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java 2008-03-10 00:10:00 UTC (rev 143) @@ -901,20 +901,6 @@ return gridletStarted; } - /** - * Updates the Gridlet's properties, such as status once a - * Gridlet is considered finished. - * @param sgl a SSGridlet object - * @param status the Gridlet status - */ - private void gridletFinish(SSGridlet sgl, int status) { - // the order is important! Set the status first then finalise - // due to timing issues in SSGridlet class - sgl.setStatus(status); - sgl.finalizeGridlet(); - super.sendFinishGridlet( sgl.getGridlet() ); - } - /* * This method obtains the queue from the profile and does a casting */ Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java 2008-03-09 02:56:01 UTC (rev 142) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java 2008-03-10 00:10:00 UTC (rev 143) @@ -722,18 +722,4 @@ return gridletStarted; } - - /** - * Updates the Gridlet's properties, such as status once a - * Gridlet is considered finished. - * @param sgl a SSGridlet object - * @param status the Gridlet status - */ - protected void gridletFinish(SSGridlet sgl, int status) { - // the order is important! Set the status first then finalise - // due to timing issues in SSGridlet class - sgl.setStatus(status); - sgl.finalizeGridlet(); - super.sendFinishGridlet( sgl.getGridlet() ); - } } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java 2008-03-09 02:56:01 UTC (rev 142) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java 2008-03-10 00:10:00 UTC (rev 143) @@ -223,7 +223,7 @@ universe.sortRanges(); boolean finished = false; - while(!finished){ + while(!finished) { finished = true; PERangeList diffRange = null; look:{ @@ -288,8 +288,6 @@ return selected; } - //TODO: The method below is not working properly. To fix it. - //TODO: As I am not using it at the moment, leave it as it is. /** * Returns the symmetric difference of two lists of ranges. * The output sequence will contain all elements that are in the ranges @@ -299,41 +297,28 @@ * @return the range corresponding to the symmetric difference */ public static PERangeList symmetricDifference(PERangeList lista, PERangeList listb){ - if(lista == null || listb == null) + if(lista == null && listb != null) + return listb.clone(); + else if(lista != null && listb == null) + return lista.clone(); + else if(lista == null && listb == null) return null; + + PERangeList difference = new PERangeList(); + PERangeList diff = difference(lista, listb); + if(diff != null && diff.size() > 0) + difference.addAll(diff); - PERangeList query = lista; - PERangeList universe = listb; - - for(PERange rangeq : query){ - boolean intersected = false; - PERangeList tempDiff = new PERangeList(); - Iterator<PERange> iterUni = universe.iterator(); - while( !intersected || iterUni.hasNext()){ - PERange rangeu = iterUni.next(); - if(intersect(rangeq, rangeu)){ - PERangeList diffRange = symmetricDifference(rangeq, rangeu); - if(diffRange != null){ - tempDiff.addAll(diffRange); - } - intersected = true; - } - else{ - tempDiff.add(rangeu); - } - } - if(!intersected){ - tempDiff.add(rangeq); - } - universe = tempDiff.clone(); - } + diff = difference(listb, lista); + if(diff != null && diff.size() > 0) + difference.addAll(diff); - if(universe == null || universe.size() == 0){ + if(difference.size() == 0){ return null; } else{ - universe.mergePERanges(); - return universe; + difference.mergePERanges(); + return difference; } } @@ -505,87 +490,8 @@ } return false; } - - /** - * Returns the symmetric difference of two ranges. The output will - * contain a list of ranges that are in one range but not in the other. - * @param rangea the first range - * @param rangeb the second range - * @return the range corresponding to the symmetric difference - */ - private static PERangeList symmetricDifference(PERange rangea, PERange rangeb){ - if(rangea == null || rangeb == null) - return null; - - int starta = rangea.getBeginning(); - int startb = rangeb.getBeginning(); - int enda = rangea.getEnd(); - int endb = rangeb.getEnd(); - - int startai = -1; - int endai = Integer.MAX_VALUE; - - int startbi = -1; - int endbi = Integer.MAX_VALUE; - - while( !(starta > enda) || !(startb > endb) ){ - if(starta < startb){ - if(startai < 0){ - startai = starta; - } - endai = starta; - starta++; - } - else if(startb < starta){ - if(startai < 0){ - startai = startb; - } - endai = startb; - startb++; - } - else{ - break; - } - } - - starta = rangea.getBeginning(); - startb = rangeb.getBeginning(); - - while( !(enda < starta) || !(endb < startb) ){ - if(enda > endb){ - if(endbi == Integer.MAX_VALUE){ - endbi = enda; - } - startbi = enda; - enda--; - } - else if(endb > enda){ - if(endbi == Integer.MAX_VALUE){ - endbi = endb; - } - startbi = endb; - endb--; - } - else{ - break; - } - } - - PERangeList difference = new PERangeList(); - if( (startai >= 0) && (endai != Integer.MAX_VALUE) ){ - PERange rBefore = new PERange(startai, endai); - difference.add(rBefore); - } - - if( (startbi >= 0) && (endbi != Integer.MAX_VALUE) ){ - PERange rAfter = new PERange(startbi, endbi); - difference.add(rAfter); - } - - return difference.size() == 0 ? null : difference; - } - // FOR DEBUGGING PURPOSES ONLY... +// // FOR DEBUGGING PURPOSES ONLY... // public static void main(String args[]){ // // PERange ra = new PERange(0, 10); @@ -600,19 +506,20 @@ //// System.out.println("Consolidated# " + list); // // PERangeList list1 = new PERangeList(); -// list1.add(ra); list1.add(rb); -// list1.add(rc); list1.add(rd); +// list1.add(new PERange(400, 1000)); +//// list1.add(ra); list1.add(rb); +//// list1.add(rc); list1.add(rd); // // PERangeList list2 = new PERangeList(); // list2.add(ra); list2.add(rb); // list2.add(rc); list2.add(rd); // // PERangeList list3 = new PERangeList(); -// list3.add(new PERange(500, 1000)); -// list3.add(new PERange(0, 499)); -// list3.add(new PERange(1001, 1005)); +// list3.add(new PERange(500, 2000)); +//// list3.add(new PERange(0, 499)); +//// list3.add(new PERange(1001, 1005)); // -// PERangeList difference = difference(null, list3); -// System.out.println("Range list " + null + " minus " + list3 + " is " + difference); +// PERangeList difference = symmetricDifference(list1, list3); +// System.out.println("Symmetric difference between list " + list1 + " and " + list3 + " is " + difference); // } } \ No newline at end of file Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java 2008-03-09 02:56:01 UTC (rev 142) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java 2008-03-10 00:10:00 UTC (rev 143) @@ -177,4 +177,18 @@ return finishTime; } + + /** + * Updates the Gridlet's properties, such as status once a + * Gridlet is considered finished. + * @param sgl a SSGridlet object + * @param status the Gridlet status + */ + protected void gridletFinish(SSGridlet sgl, int status) { + // the order is important! Set the status first then finalise + // due to timing issues in SSGridlet class + sgl.setStatus(status); + sgl.finalizeGridlet(); + super.sendFinishGridlet( sgl.getGridlet() ); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |