|
From: <sul...@us...> - 2007-08-29 01:00:28
|
Revision: 36
http://gridsim.svn.sourceforge.net/gridsim/?rev=36&view=rev
Author: sulistio
Date: 2007-08-28 18:00:27 -0700 (Tue, 28 Aug 2007)
Log Message:
-----------
when record an event to a file, remove putting this entity name. it is redundant.
Modified Paths:
--------------
branches/gridsim4.0-branch1/source/gridsim/resFailure/GridResourceWithFailure.java
Modified: branches/gridsim4.0-branch1/source/gridsim/resFailure/GridResourceWithFailure.java
===================================================================
--- branches/gridsim4.0-branch1/source/gridsim/resFailure/GridResourceWithFailure.java 2007-08-28 09:29:09 UTC (rev 35)
+++ branches/gridsim4.0-branch1/source/gridsim/resFailure/GridResourceWithFailure.java 2007-08-29 01:00:27 UTC (rev 36)
@@ -4,7 +4,7 @@
* of Parallel and Distributed Systems such as Clusters and Grids
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
- * Author: Agustin Caminero
+ * Author: Agustin Caminero and Anthony Sulistio
* Organization: Universidad de Castilla La Mancha (UCLM), Spain.
* Created on: Nov 2006.
*/
@@ -31,7 +31,7 @@
* with properties defined in an object of
* {@link gridsim.ResourceCharacteristics} class.
*
- * @author Agustin Caminero
+ * @author Agustin Caminero and Anthony Sulistio
* @since GridSim Toolkit 4.1
* @see gridsim.GridResource
* @see gridsim.ResourceCharacteristics
@@ -396,12 +396,16 @@
/**
* Asks this resource to record its activities. <br>
- * NOTE: this method should be called <b>BEFORE</b> the ssimulation starts.
+ * NOTE: this method should be called <b>BEFORE</b> the simulation starts.
+ * If an existing file exists, the new activities will be appended at the
+ * end. The file name is this entity name.
+ *
* @param trace <tt>true</tt> if you want to record this resource's
* activities, <tt>false</tt> otherwise
*/
public void setTrace(boolean trace) {
record_ = trace;
+ initializeReportFile();
}
/**
@@ -465,9 +469,6 @@
// Below method is for a child class to override
registerOtherEntity();
- // Put the headers on each column in the results file
- initializeReportFile();
-
// Process events until END_OF_SIMULATION is received from the
// GridSimShutdown Entity
Sim_event ev = new Sim_event();
@@ -1311,7 +1312,7 @@
}
try {
- fwriter.write("Resource \t Event \t NumMachines \t Clock\n");
+ fwriter.write("Event \t NumMachines \t Clock\n");
}
catch (Exception ex)
{
@@ -1332,11 +1333,15 @@
}
/**
- * Writes some data into a results file.
- * @param event Values: "Failure" or "Recovery" of a resource
- * @param numMachiens number of machines
+ * Write an event of this entity into a file.
+ * If an existing file exists, the new event will be appended at the end.
+ * The file name is this entity name.
+ *
+ * @param event Values: "Removing" or "Registering" a resource
+ * @param resID resource id
+ * @param clock Current time
*/
- private void write(String event, int numMachines)
+ protected void write(String event, int numMachines)
{
if (record_ == false) {
return;
@@ -1348,17 +1353,19 @@
try
{
fwriter = new FileWriter(this.get_name(), true);
- } catch (Exception ex)
+ }
+ catch (Exception ex)
{
ex.printStackTrace();
System.out.println("Unwanted errors while opening file " +
this.get_name());
}
+
try
{
- fwriter.write(this.get_name() + "\t " + event+ " \t" + numMachines +
- " \t" + GridSim.clock() + "\n");
- } catch (Exception ex)
+ fwriter.write(event+ " \t"+ numMachines+ " \t"+GridSim.clock()+"\n");
+ }
+ catch (Exception ex)
{
ex.printStackTrace();
System.out.println("Unwanted errors while writing on file " +
@@ -1368,7 +1375,8 @@
try
{
fwriter.close();
- } catch (Exception ex)
+ }
+ catch (Exception ex)
{
ex.printStackTrace();
System.out.println("Unwanted errors while closing file " +
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|