📄 test.java
字号:
output +="Sending " + info + " to Resource " + resourceName[id] + ", ID: " + resourceID[id] + "\n";
// send one GroupGridlet to the assigned Grid resource
gridletSubmit(gridlet, resourceID[id], 0.0, false);
// record this event into "stat.txt" file
recordStatistics("\"Submit " + info + " to " + resourceName[id] + "\"", "");
i++;
}
// receive the GroupGridlets from the I/O queue
output += "\n======================== Receiving Processed Gridlets ========================\n";
i=0;
while(i < list2.size())
{
// waiting to receive a Gridlet back from resource entity
gridlet = this.gridletReceive();
// when a Grid resource finished processing the Gridlet, set the resource ID and its cost to perform the job
gridlet.setResourceParameter( gridlet.getResourceID() , gridlet.getCostPerSec());
info = "GroupedGridlet " + gridlet.getGridletID();
output +="Receiving " + info + " from " + gridlet.getResourceName(gridlet.getResourceID()) + ", ID: " + gridlet.getResourceID() + "\n";
// recod this event into "stat.txt" file for statistical purposes
recordStatistics("\"Received " + info + " from " +gridlet.getResourceName(gridlet.getResourceID())
+ "\"", gridlet.getProcessingCost());
// store the received Gridlet into a new GridletList object
this.receiveList_.add(gridlet);
i++;
}
output += "\n==============================================================================\n";
// total overhead time
overhead = overhead*list2.size();
} // End of If
else
{
for(i = 0; i < this.list_.size();) // loop to get the Gridlet
{
for(n=0; n < this.totalResource_ && i < this.list_.size(); n++, i++) // loop to get the resource
{
total_length = 0.0;
MIPS_Rate_Machine = 0.0;
id = n;
// get MIPS of a resource
MIPS_Rate_Machine = resourceMIPS[id]*granTime;
output += "\nThe supported MI for granularity time " + granTime + " second(s), by Resource "
+ resourceName[id] + " (ID:" + resourceID[id] + ")" + " is " + MIPS_Rate_Machine + "\n";
// get one Gridlet
gridlet = (Gridlet) this.list_.get(i);
while((total_length <= MIPS_Rate_Machine) && (i< this.list_.size()))
{
gridlet = (Gridlet) this.list_.get(i);
total_length = total_length + gridlet.getGridletLength();
// send Gridlet to the Grid resource
info = "Gridlet " + gridlet.getGridletID();
output +="Sending " + info + " to " + resourceName[id] + ", ID: " + resourceID[id] + "; Total MI or length sent: " + total_length + "\n";
// send one GroupGridlet to the assigned Grid resource
gridletSubmit(gridlet, resourceID[id], 0.0, false);
// record this event into "stat.txt" file
recordStatistics("\"Submit " + info + " to " + resourceName[id] + "\"", "");
i++;
}
i=i-1;
}
}
// receive the GroupGridlets from the I/O queue
output += "\n======================== Receiving Processed Gridlets ========================\n";
i=0;
while(i < this.list_.size())
{
// waiting to receive a Gridlet back from resource entity
gridlet = this.gridletReceive();
// when a Grid resource finished processing the Gridlet, set the resource ID and its cost to perform the job
gridlet.setResourceParameter( gridlet.getResourceID() , gridlet.getCostPerSec());
info = "GroupedGridlet " + gridlet.getGridletID();
output +="Receiving " + info + " from " + gridlet.getResourceName(gridlet.getResourceID()) + ", ID: " + gridlet.getResourceID() + "\n";
// recod this event into "stat.txt" file for statistical purposes
recordStatistics("\"Received " + info + " from " +gridlet.getResourceName(gridlet.getResourceID())
+ "\"", gridlet.getProcessingCost());
// store the received Gridlet into a new GridletList object
this.receiveList_.add(gridlet);
i++;
}
output += "\n==============================================================================\n";
// total overhead time
overhead = overhead*this.list_.size();
}
Time2 = clock(); // get the finish time
Total_Time = Time2-Time1; // total simulation time
output += "\nTotal overhead time: " + df.format(overhead) + " seconds";
output += "\nTotal Simulation Time: " + df.format(Total_Time) + " seconds";
Total_Time = Total_Time + (double)overhead;
output += "\nTotal Time: " + df.format(Total_Time) + " seconds\n";
printGridletList(receiveList_, grouping, FGridlet, LGridlet, processedGridlet); // print out the info regarding received GroupGridlets
// terminate the simulation activity
shutdownGridStatisticsEntity();
shutdownUserEntity();
terminateIOEntities();
}
/**********************************************
Gets the list of Gridlets
**********************************************/
public GridletList getGridletList() {
return this.receiveList_;
}
/*************************************************************************
This createGridlet method creates Gridlets based on user specified MIPS
*************************************************************************/
private GridletList createGridlet(int userID)
{
// creates a list to store Gridlets
GridletList list = new GridletList();
// variable declarations
int id = 0;
double length;
long file_size;
long output_size;
double rateDP;
// create Gridlets by using the seed for the random function
long seed = 11L*13*17*19*23+1;
Random random = new Random(seed);
// convert the deviate percentage from % form to point form
rateDP = (double)deviatePercentage/100.0;
for (int i = 0; i < numOfGridlets; i++)
{
// Gridlet length that varies within the range of user specified MI rating +/- MI deviation %
length = (double) GridSimRandom.real(averageMI,rateDP,rateDP,random.nextDouble());
// Gridlet file size that varies within the range 500 +/- 10%
file_size = (long) GridSimRandom.real(500,0.1,0.1,random.nextDouble());
// Gridlet output size that varies within the range 500 +/- 10%
output_size = (long) GridSimRandom.real(500,0.1,0.1,random.nextDouble());
// creates a new Gridlet object
Gridlet gridlet = new Gridlet(id + i, length, file_size, output_size);
// set user ID for the Gridlets
gridlet.setUserID(userID);
// add the Gridlet into a list
list.add(gridlet);
}
return list;
}
/***********************************************************
Prints the received GroupGridlets from the Grid resources
***********************************************************/
private void printGridletList(GridletList list, boolean grouping, LinkedList FGridlet, LinkedList LGridlet, int processedGridlet)
{
int F, L;
Gridlet gridlet;
int size = list.size();
String tab = "\t";
double total_cost = 0.0;
output +="\n============================== SIMULATION RESULTS========================================\n";
if(grouping == true)
{
output +="GroupedGridlet ID" + tab + "Gridlets" + tab + "STATUS" + tab
+ "Resource Name/ID" + tab + "Total Load" + tab + "Cost" + tab
+ "Start Time" + tab + "Finish Time\n";
for (int i = 0; i < size; i++)
{
gridlet = (Gridlet) list.get(i);
output += gridlet.getGridletID();
F = ((Integer)FGridlet.get(i)).intValue();
L = ((Integer)LGridlet.get(i)).intValue();
output += tab + tab + F + " - " + L;
if (gridlet.getGridletStatus() == gridlet.SUCCESS)
output += tab + "SUCCESS"; // the GroupGridlet has been executed successfully
else
output += tab + "NOT SUCCESS"; // the GroupGridlet is not executed successfully
output += tab + gridlet.getResourceName(gridlet.getResourceID()) + "/"
+ gridlet.getResourceID() + tab + tab + df.format(gridlet.getGridletLength())
+ tab + df.format(gridlet.getProcessingCost()) + tab + df.format(gridlet.getExecStartTime())
+ tab + df.format(gridlet.getFinishTime()) + "\n";
total_cost += gridlet.getProcessingCost();
}
output +="============================================================================================\n";
}
else
{
output +="Gridlet ID" + tab + "STATUS" + tab + "Resource Name/ID" + tab + "Total Load" + tab + "Cost"
+ tab + "Start Time" + tab + "Finish Time" + "\n";
for (int i = 0; i < size; i++)
{
gridlet = (Gridlet) list.get(i);
output += gridlet.getGridletID();
if (gridlet.getGridletStatus() == gridlet.SUCCESS)
output += tab + "SUCCESS"; // the GroupGridlet has been executed successfully
else
output += tab + "NOT SUCCESS"; // the GroupGridlet is not executed successfully
output += tab + gridlet.getResourceName(gridlet.getResourceID()) + "/"
+ gridlet.getResourceID() + tab + tab + df.format(gridlet.getGridletLength())
+ tab + df.format(gridlet.getProcessingCost()) + tab + df.format(gridlet.getExecStartTime())
+ tab + df.format(gridlet.getFinishTime())+ "\n";
total_cost += gridlet.getProcessingCost();
}
output +="============================================================================================\n";
}
output +="Total Gridlet processing cost: " + df.format(total_cost) + "\n";
// display the info about processed Gridlets within the given granularity time
if(processedGridlet == 0)
output +="All the Gridlets are processed within the given granularity time\n";
else
{
output +="Time taken to process all the Gridlets is more than the given granularity time\n";
output +="Total number of Gridlets that are processed within the granularity time: " + processedGridlet + "\n";
}
}// recordStatistics("\"Received " + info + " from " +Gridlet.getResourceName(Gridlet.getResourceID()) + "\"", Gridlet.getProcessingCost());
} // end class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -