GridSim 5.0 beta

gridsim.datagrid
Class SimpleReplicaManager

Object
  extended by Thread
      extended by Sim_entity
          extended by ReplicaManager
              extended by SimpleReplicaManager
All Implemented Interfaces:
Cloneable, Runnable

public class SimpleReplicaManager
extends ReplicaManager

This is a class which contains the basic functionality of a Replica Manager in a Data Grid. The current functionlity provided by this implementation includes the following:

Since:
GridSim Toolkit 4.0
Author:
Uros Cibej and Anthony Sulistio

Nested Class Summary
 
Nested classes/interfaces inherited from class Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class ReplicaManager
outputPort_, policy_, rcID_, resIdObj_, resourceID_, storageList_
 
Fields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SimpleReplicaManager(String name, String resourceName)
          Creates a new Replica Manager object
 
Method Summary
protected  int addFile(File file)
          Adds a file to the local storage.
 boolean addStorage(List storageList)
          Adds a list of storage elements to the DataGrid resource
 boolean addStorage(Storage storage)
          Adds a storage element to the DataGrid resource
 void body()
          The main method of the data manager, which is responsible for managing all the incoming events.
protected  int deleteFile(String fileName)
          Deletes a file from the local storage, and registers the change to the designated Replica Catalogue.
protected  File getFile(String fileName)
          Gets a physical file based on its name
 boolean processEvent(Sim_event ev)
          Processes an incoming event
protected  boolean receiveFileDelivery(File file)
          A requested file has been delivered by another resource.
protected  void receiveReplicaLocation(Sim_event ev)
          A location of the file is returned from the RC.
 void registerAllMasterFiles()
          Registers all files (as master files) present on the storage(s) when GridSim is started.
 
Methods inherited from class ReplicaManager
contains, contains, deregisterDeletedFile, getTotalStorageCapacity, init, processEndSimulation, registerFile, registerFile, setReplicaCatalogue, setReplicaCatalogue
 
Methods inherited from class Sim_entity
add_generator, add_param, add_port, clone, get_id, get_name, get_port, get_port, get_stat, run, send_on, set_invisible, set_stat, sim_cancel, sim_completed, sim_current, sim_get_next, sim_get_next, sim_hold_for, sim_hold, sim_pause_for, sim_pause_for, sim_pause_until, sim_pause_until, sim_pause, sim_process_for, sim_process_for, sim_process_until, sim_process_until, sim_process, sim_putback, sim_schedule, sim_schedule, sim_schedule, sim_schedule, sim_schedule, sim_schedule, sim_select, sim_trace, sim_wait_for, sim_wait_for, sim_wait_for, sim_wait, sim_waiting, sim_waiting
 
Methods inherited from class Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleReplicaManager

public SimpleReplicaManager(String name,
                            String resourceName)
                     throws ParameterException
Creates a new Replica Manager object

Parameters:
name - the name to be associated with this entity
resourceName - the name of the DataGrid resource
Throws:
ParameterException - This happens when one of the following scenarios occur:
  • creating this entity before initializing GridSim package
  • the given name is null or empty
See Also:
GridSim.init(int, Calendar, boolean, String[], String[], String)
Method Detail

addFile

protected int addFile(File file)
Adds a file to the local storage. However, the file is not registered to the Replica Catalogue.
In this implementation, it looks through all the available storages if there is some space. It stores on the first storage that has enough space. In addition, we assume all files are read-only. Hence, existing files can not be overwritten.

Specified by:
addFile in class ReplicaManager
Parameters:
file - a file to be placed on the local resource
Returns:
an integer number denoting whether this operation is successful or not
See Also:
DataGridTags.FILE_ADD_SUCCESSFUL, DataGridTags.FILE_ADD_ERROR_STORAGE_FULL

addStorage

public boolean addStorage(List storageList)
Adds a list of storage elements to the DataGrid resource

Specified by:
addStorage in class ReplicaManager
Parameters:
storageList - a list of storage elements to be added
Returns:
true if successful, false otherwise

addStorage

public boolean addStorage(Storage storage)
Adds a storage element to the DataGrid resource

Specified by:
addStorage in class ReplicaManager
Parameters:
storage - the storage element to be added
Returns:
true if successful, false otherwise

deleteFile

protected int deleteFile(String fileName)
Deletes a file from the local storage, and registers the change to the designated Replica Catalogue.

Specified by:
deleteFile in class ReplicaManager
Parameters:
fileName - the filename of the file to be deleted.
Returns:
an integer number denoting whether this operation is successful or not
See Also:
DataGridTags.FILE_DELETE_SUCCESSFUL, DataGridTags.FILE_DELETE_ERROR_READ_ONLY

getFile

protected File getFile(String fileName)
Gets a physical file based on its name

Specified by:
getFile in class ReplicaManager
Parameters:
fileName - the file name to be retrieved
Returns:
the physical file or null if not found

body

public void body()
The main method of the data manager, which is responsible for managing all the incoming events.

Overrides:
body in class Sim_entity

processEvent

public boolean processEvent(Sim_event ev)
Processes an incoming event

Specified by:
processEvent in class ReplicaManager
Returns:
true if successful, false otherwise

registerAllMasterFiles

public void registerAllMasterFiles()
Registers all files (as master files) present on the storage(s) when GridSim is started.

Specified by:
registerAllMasterFiles in class ReplicaManager

receiveReplicaLocation

protected void receiveReplicaLocation(Sim_event ev)
A location of the file is returned from the RC. This function sends a request for transferring the file. It also checks the network QoS for this file.

Parameters:
ev - a Sim_event object

receiveFileDelivery

protected boolean receiveFileDelivery(File file)
A requested file has been delivered by another resource.

Parameters:
file - a File object
Returns:
true if this delivery has been acknowledged, false otherwise

GridSim 5.0 beta

The University of Melbourne, Australia, 2009