Skip to content

Commit

Permalink
refactor the entire workflowsim
Browse files Browse the repository at this point in the history
  • Loading branch information
Weiwei Chen committed Mar 24, 2015
1 parent d3adfd4 commit efaf781
Show file tree
Hide file tree
Showing 52 changed files with 743 additions and 1,043 deletions.
8 changes: 4 additions & 4 deletions sources/org/workflowsim/ClusterStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class ClusterStorage extends HarddriveStorage {
/**
* The map stores the bandwidth from this cluster-storage to others
*/
Map bandwidthMap;
Map<String, Double> bandwidthMap;

/**
* Initialize a ClusterStorage
Expand Down Expand Up @@ -67,12 +67,12 @@ public final void setBandwidth(String name, double bandwidth) {
* @param destination
* @return bandwidth
*/
public double getMaxTransferRate(String destination) {
public double getMaxBandwidth(String destination) {
if (bandwidthMap.containsKey(destination)) {
return (Double) bandwidthMap.get(destination);
return bandwidthMap.get(destination);
} else {
//local bandwidth between vms
return (Double) bandwidthMap.get("local");
return bandwidthMap.get("local");
}
}
}
53 changes: 0 additions & 53 deletions sources/org/workflowsim/CondorVM.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
*/
public class CondorVM extends Vm {

/*
* The local storage system a vm has if file.system=LOCAL
*/
private ClusterStorage storage;
/*
* The state of a vm. It should be either WorkflowSimTags.VM_STATUS_IDLE
* or VM_STATUS_READY (not used in workflowsim) or VM_STATUS_BUSY
Expand Down Expand Up @@ -97,15 +93,6 @@ public CondorVM(
* At the beginning all vm status is idle.
*/
setState(WorkflowSimTags.VM_STATUS_IDLE);
/*
* If the file.system is LOCAL, we should add a clusterStorage to vm.
*/
if (ReplicaCatalog.getFileSystem() == FileSystem.LOCAL) {
try {
storage = new ClusterStorage(Integer.toString(id), 1e6);
} catch (Exception e) {
}
}
}

/**
Expand Down Expand Up @@ -210,44 +197,4 @@ public final void setState(int tag) {
public final int getState() {
return this.state;
}

/**
* Adds a file to the local file system
*
* @param file to file to be added to the local
* @pre $none
* @post $none
*/
public void addLocalFile(org.cloudbus.cloudsim.File file) {
if (this.storage != null) {
this.storage.addFile(file);
} else {
}
}

/**
* Removes a file from the local file system
*
* @param file to file to be removed to the local
* @pre $none
* @post $none
*/
public void removeLocalFile(org.cloudbus.cloudsim.File file) {
if (this.storage != null) {
this.storage.deleteFile(file);
}
}

/**
* Tells whether a file is in the local file system
*
* @param file
* @return whether the file exists in the local file system
*/
public boolean hasLocalFile(org.cloudbus.cloudsim.File file) {
if (this.storage != null) {
return this.storage.contains(file);
}
return false;
}
}
67 changes: 67 additions & 0 deletions sources/org/workflowsim/FileItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* Copyright 2014-2015 University Of Southern California
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.workflowsim;

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.
* @author weiweich
*/
public class FileItem {

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;
}
}
16 changes: 8 additions & 8 deletions sources/org/workflowsim/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class Task extends Cloudlet {
/*
* The list of all files (input data and ouput data)
*/
private List<org.cloudbus.cloudsim.File> fileList;
private List<FileItem> fileList;
/*
* The priority used for research. Not used in current version.
*/
Expand All @@ -71,7 +71,7 @@ public class Task extends Cloudlet {
* The finish time of a task (Because cloudlet does not allow WorkflowSim to
* update finish_time)
*/
private double task_finish_time;
private double taskFinishTime;

/**
* Allocates a new Task object. The task length should be greater than or
Expand Down Expand Up @@ -100,7 +100,7 @@ public Task(
this.parentList = new ArrayList<>();
this.fileList = new ArrayList<>();
this.impact = 0.0;
this.task_finish_time = -1.0;
this.taskFinishTime = -1.0;
}

/**
Expand Down Expand Up @@ -238,7 +238,7 @@ public void addParent(Task task) {
* @pre $none
* @post $none
*/
public List getFileList() {
public List<FileItem> getFileList() {
return this.fileList;
}

Expand All @@ -247,7 +247,7 @@ public List getFileList() {
*
* @param file, the file to be added
*/
public void addFile(org.cloudbus.cloudsim.File file) {
public void addFile(FileItem file) {
this.fileList.add(file);
}

Expand All @@ -256,7 +256,7 @@ public void addFile(org.cloudbus.cloudsim.File file) {
*
* @param list, the file list
*/
public void setFileList(List<org.cloudbus.cloudsim.File> list) {
public void setFileList(List<FileItem> list) {
this.fileList = list;
}

Expand Down Expand Up @@ -286,7 +286,7 @@ public double getImpact() {
* @param time finish time
*/
public void setTaskFinishTime(double time) {
this.task_finish_time = time;
this.taskFinishTime = time;
}

/**
Expand All @@ -295,7 +295,7 @@ public void setTaskFinishTime(double time) {
* @return
*/
public double getTaskFinishTime() {
return this.task_finish_time;
return this.taskFinishTime;
}

/**
Expand Down
20 changes: 8 additions & 12 deletions sources/org/workflowsim/WorkflowDatacenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.cloudbus.cloudsim.Consts;
import org.cloudbus.cloudsim.Datacenter;
import org.cloudbus.cloudsim.DatacenterCharacteristics;
import org.cloudbus.cloudsim.File;
import org.cloudbus.cloudsim.Host;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Storage;
Expand Down Expand Up @@ -196,10 +195,9 @@ private void updateTaskExecTime(Job job, Vm vm) {
*/
private void stageInFile2FileSystem(Cloudlet cl) {
Task t1 = (Task) cl;
List fList = t1.getFileList();
List<FileItem> fList = t1.getFileList();

for (Iterator it = fList.iterator(); it.hasNext();) {
org.cloudbus.cloudsim.File file = (org.cloudbus.cloudsim.File) it.next();
for (FileItem file : fList) {
switch (ReplicaCatalog.getFileSystem()) {
/**
* For local file system, add it to local storage (data center
Expand Down Expand Up @@ -238,15 +236,15 @@ private void stageInFile2FileSystem(Cloudlet cl) {
* @pre $none
* @post $none
*/
private boolean isRealInputFile(List<File> list, File file) {
if (file.getType() == FileType.INPUT.value)//input file
private boolean isRealInputFile(List<FileItem> list, FileItem file) {
if (file.getType() == FileType.INPUT)//input file
{
for (File another : list) {
for (FileItem another : list) {
if (another.getName().equals(file.getName())
/**
* if another file is output file
*/
&& another.getType() == FileType.OUTPUT.value) {
&& another.getType() == FileType.OUTPUT) {
return false;
}
}
Expand All @@ -262,11 +260,9 @@ private boolean isRealInputFile(List<File> list, File file) {
* @post $none
*/

protected double processDataStageIn(List<File> requiredFiles, Cloudlet cl) throws Exception {
protected double processDataStageIn(List<FileItem> requiredFiles, Cloudlet cl) throws Exception {
double time = 0.0;
Iterator<File> iter = requiredFiles.iterator();
while (iter.hasNext()) {
File file = iter.next();
for (FileItem file : requiredFiles) {
//The input file is not an output File
if (isRealInputFile(requiredFiles, file)) {
double maxBwth = 0.0;
Expand Down
Loading

0 comments on commit efaf781

Please sign in to comment.