Skip to content

Commit

Permalink
Fix bug #17 to remove duplicate isRealInputFile
Browse files Browse the repository at this point in the history
  • Loading branch information
Weiwei Chen committed Mar 24, 2015
1 parent 6cd11de commit d4b4562
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 113 deletions.
33 changes: 1 addition & 32 deletions sources/org/workflowsim/ClusteringEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.workflowsim.utils.ClusteringParameters;
import org.workflowsim.utils.Parameters;
import org.workflowsim.utils.Parameters.ClassType;
import org.workflowsim.utils.Parameters.FileType;
import org.workflowsim.utils.ReplicaCatalog;

/**
Expand Down Expand Up @@ -183,36 +182,6 @@ else if (params.getClustersSize() != 0) {
setJobList(engine.getJobList());
}

/**
* Checks whether a file is an input file alone (not a output file)
*
* @param list, the list of all files
* @param file, the file to be checked
* @return
*/
private boolean isRealInputFile(List<FileItem> list, FileItem file) {
/**
* if the type is input file)
*/
if (file.getType() == FileType.INPUT) {
for (FileItem another : list) {
/**
* if there is another file that has the same name and it is
* output file
*/
if (another.getName().equals(file.getName())
/**
* It is output file
*/
&& another.getType() == FileType.OUTPUT) {
return false;
}
}
return true;
}
return false;
}

/**
* Adds data stage-in jobs to the job list
*/
Expand Down Expand Up @@ -240,7 +209,7 @@ protected void processDatastaging() {
/**
* To avoid duplicate files
*/
if (isRealInputFile(list, file)) {
if (file.isRealInputFile(list)) {
ReplicaCatalog.addFileToStorage(file.getName(), Parameters.SOURCE);
fileList.add(file);
}
Expand Down
65 changes: 46 additions & 19 deletions sources/org/workflowsim/FileItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,53 +15,80 @@
*/
package org.workflowsim;

import java.util.List;
import org.workflowsim.utils.Parameters.FileType;

/**
* This is a file implementation in WorkflowSim. Since CloudSim has already implemented File,
* we call it FileItem here. The reason it is here is WorkflowSim has a different view
* of files.
* Case 1: in org.cloudsim.File, file size is integer, while in our case
* it should be double sine we have many big files. Also, we would like to precisely estimate
* the transfer delay.
* Case 2: we would like to specify the type (input, output, intermediate) which is a different
* concept to the type in CloudSim.
* This is a file implementation in WorkflowSim. Since CloudSim has already
* implemented File, we call it FileItem here. The reason it is here is
* WorkflowSim has a different view of files. Case 1: in org.cloudsim.File, file
* size is integer, while in our case it should be double sine we have many big
* files. Also, we would like to precisely estimate the transfer delay. Case 2:
* we would like to specify the type (input, output, intermediate) which is a
* different concept to the type in CloudSim.
*
* @author weiweich
*/
public class FileItem {
private String name;

private String name;

private double size;

private FileType type;

public FileItem(String name, double size) {
this.name = name;
this.size = size;
}

public void setName(String name) {
this.name = name;
}

public void setSize(double size) {
this.size = size;
}

public void setType(FileType type) {
this.type = type;
}

public String getName() {
return this.name;
}

public double getSize() {
return this.size;
}

public FileType getType() {
return this.type;
}

/**
* If a input file has an output file it does not need stage-in For
* workflows, we have a rule that a file is written once and read many
* times, thus if a file is an output file it means it is generated within
* this job and then used by another task within the same job (or other jobs
* maybe) This is useful when we perform horizontal clustering
* @param list
* @return
*/
public boolean isRealInputFile(List<FileItem> list) {
if (this.getType() == FileType.INPUT)//input file
{
for (FileItem another : list) {
if (another.getName().equals(this.getName())
/**
* if another file is output file
*/
&& another.getType() == FileType.OUTPUT) {
return false;
}
}
return true;
}
return false;
}
}
30 changes: 1 addition & 29 deletions sources/org/workflowsim/WorkflowDatacenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,34 +219,6 @@ private void stageInFile2FileSystem(Job job) {
}
}

/**
* If a input file has an output file it does not need stage-in For
* workflows, we have a rule that a file is written once and read many
* times, thus if a file is an output file it means it is generated within
* this job and then used by another job within the same job (or other jobs
* maybe) This is useful when we perform horizontal clustering
*
* @param list, the list of all files
* @param file, the file to be examined
* @pre $none
* @post $none
*/
private boolean isRealInputFile(List<FileItem> list, FileItem file) {
if (file.getType() == FileType.INPUT)//input file
{
for (FileItem another : list) {
if (another.getName().equals(file.getName())
/**
* if another file is output file
*/
&& another.getType() == FileType.OUTPUT) {
return false;
}
}
return true;
}
return false;
}
/*
* Stage in for a single job (both stage-in job and compute job)
* @param requiredFiles, all files to be stage-in
Expand All @@ -259,7 +231,7 @@ protected double processDataStageIn(List<FileItem> requiredFiles, Job job) throw
double time = 0.0;
for (FileItem file : requiredFiles) {
//The input file is not an output File
if (isRealInputFile(requiredFiles, file)) {
if (file.isRealInputFile(requiredFiles)) {
double maxBwth = 0.0;
List siteList = ReplicaCatalog.getStorageList(file.getName());
if (siteList.isEmpty()) {
Expand Down
2 changes: 0 additions & 2 deletions sources/org/workflowsim/clustering/TaskSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ public TaskSet() {
this.childList = new ArrayList<>();
this.hasChecked = false;
this.impactFactor = 0.0;


}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.workflowsim.FileItem;
import org.workflowsim.Job;
import org.workflowsim.WorkflowSimTags;
import org.workflowsim.utils.Parameters.FileType;
import org.workflowsim.utils.ReplicaCatalog;

/**
Expand Down Expand Up @@ -71,35 +70,7 @@ public void run() {
}
}
}

/**
* If a input file has an output file it does not need stage-in For
* workflows, we have a rule that a file is written once and read many
* times, thus if a file is an output file it means it is generated within
* this job and then used by another task within the same job (or other jobs
* maybe) This is useful when we perform horizontal clustering
*
* @param list, the list of all files
* @param file, the file to be examined
* @pre $none
* @post $none
*/
private boolean isRealInputFile(List<FileItem> list, FileItem file) {
if (file.getType() == FileType.INPUT)//input file
{
for (FileItem another : list) {
if (another.getName().equals(file.getName())
/**
* if another file is output file
*/
&& another.getType() == FileType.OUTPUT) {
return false;
}
}
return true;
}
return false;
}

/*
* Stage in for a single job (both stage-in job and compute job)
* @param requiredFiles, all files to be stage-in
Expand All @@ -113,7 +84,7 @@ protected double dataTransferTime(List<FileItem> requiredFiles, Cloudlet cl, int

for (FileItem file : requiredFiles) {
//The input file is not an output File
if (isRealInputFile(requiredFiles, file)) {
if (file.isRealInputFile(requiredFiles)) {
List<String> siteList = ReplicaCatalog.getStorageList(file.getName());

boolean hasFile = false;
Expand Down

0 comments on commit d4b4562

Please sign in to comment.