GridSim 5.0 beta

gridsim.datagrid
Class File

Object
  extended by File

public class File
extends Object

A class for representing a physical file in a DataGrid environment

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

Field Summary
static int NOT_REGISTERED
          Denotes that this file has not been registered to a Replica Catalogue
static int TYPE_RAW_DATA
          Denotes that the type of this file is a raw data
static int TYPE_RECONSTRUCTED_DATA
          Denotes that the type of this file is a reconstructed data
static int TYPE_TAG_DATA
          Denotes that the type of this file is a tag data
static int TYPE_UNKOWN
          Denotes that the type of this file is unknown
 
Constructor Summary
File(File file)
          Copy constructor, i.e.
File(String fileName, int fileSize)
          Creates a new DataGrid file with a given size (in MBytes).
 
Method Summary
 int getAttributeSize()
          Gets the size of this object (in byte).
NOTE: This object size is NOT the actual file size.
 int getChecksum()
          Gets the file checksum
 double getCost()
          Gets the cost associated with this file
 long getCreationTime()
          Gets the file creation time (in millisecond)
 FileAttribute getFileAttribute()
          Gets an attribute of this file
 double getLastUpdateTime()
          Gets the last update time (in seconds)
 String getName()
          Returns the file name
 String getOwnerName()
          Gets the owner name of this file
 int getRegistrationID()
          Gets the file registration ID
 int getResourceID()
          Gets the resource ID that stores this file
 int getSize()
          Gets the file size (in MBytes)
 int getSizeInByte()
          Gets the file size (in bytes)
 double getTransactionTime()
          Gets the last transaction time of this file (in second).
 int getType()
          Gets this file type
 boolean isMasterCopy()
          Checks whether this file is a master copy or replica
 boolean isReadOnly()
          Checks whether this file is a read only or not
 boolean isRegistered()
          Checks if this file already registered to a Replica Catalogue
 File makeMasterCopy()
          Clone this file and make the new file as a master copy as well
 File makeReplica()
          Clone this file but the clone file is set to a replica
 boolean setChecksum(int checksum)
          Sets the checksum of this file
 boolean setCost(double cost)
          Sets the cost associated with this file
 boolean setFileSize(int fileSize)
          Sets the file size (in MBytes)
 void setMasterCopy(boolean masterCopy)
          Marks this file as a master copy or replica
 void setName(String name)
          Sets the file name
 boolean setOwnerName(String name)
          Sets the owner name of this file
 void setReadOnly(boolean readOnly)
          Marks this file as a read only or not
 boolean setRegistrationID(int id)
          Sets the file registration ID (published by a Replica Catalogue entity)
 boolean setResourceID(int resourceID)
          Sets the resource ID that stores this file
 boolean setTransactionTime(double time)
          Sets the current transaction time (in second) of this file.
 boolean setType(int type)
          Sets the file type (e.g.
 boolean setUpdateTime(double time)
          Sets the last update time of this file (in seconds)
NOTE: This time is relative to the start time.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOT_REGISTERED

public static final int NOT_REGISTERED
Denotes that this file has not been registered to a Replica Catalogue

See Also:
Constant Field Values

TYPE_UNKOWN

public static final int TYPE_UNKOWN
Denotes that the type of this file is unknown

See Also:
Constant Field Values

TYPE_RAW_DATA

public static final int TYPE_RAW_DATA
Denotes that the type of this file is a raw data

See Also:
Constant Field Values

TYPE_RECONSTRUCTED_DATA

public static final int TYPE_RECONSTRUCTED_DATA
Denotes that the type of this file is a reconstructed data

See Also:
Constant Field Values

TYPE_TAG_DATA

public static final int TYPE_TAG_DATA
Denotes that the type of this file is a tag data

See Also:
Constant Field Values
Constructor Detail

File

public File(String fileName,
            int fileSize)
     throws ParameterException
Creates a new DataGrid file with a given size (in MBytes).
NOTE: By default, a newly-created file is set to a master copy.

Parameters:
fileName - file name
fileSize - file size is in MBytes
Throws:
ParameterException - This happens when one of the following scenarios occur:
  • the file name is empty or null
  • the file size is zero or negative numbers

File

public File(File file)
     throws ParameterException
Copy constructor, i.e. cloning from a source file into this object, but this object is set to a replica

Parameters:
file - the source of a File object to copy
Throws:
ParameterException - This happens when the source file is null
Method Detail

makeReplica

public File makeReplica()
Clone this file but the clone file is set to a replica

Returns:
a clone of this file (as a replica) or null if an error occurs

makeMasterCopy

public File makeMasterCopy()
Clone this file and make the new file as a master copy as well

Returns:
a clone of this file (as a master copy) or null if an error occurs

getFileAttribute

public FileAttribute getFileAttribute()
Gets an attribute of this file

Returns:
a file attribute

getAttributeSize

public int getAttributeSize()
Gets the size of this object (in byte).
NOTE: This object size is NOT the actual file size. Moreover, this size is used for transferring this object over a network.

Returns:
the object size (in byte)

setResourceID

public boolean setResourceID(int resourceID)
Sets the resource ID that stores this file

Parameters:
resourceID - a resource ID
Returns:
true if successful, false otherwise

getResourceID

public int getResourceID()
Gets the resource ID that stores this file

Returns:
the resource ID

getName

public String getName()
Returns the file name

Returns:
the file name

setName

public void setName(String name)
Sets the file name

Parameters:
name - the file name

setOwnerName

public boolean setOwnerName(String name)
Sets the owner name of this file

Parameters:
name - the owner name
Returns:
true if successful, false otherwise

getOwnerName

public String getOwnerName()
Gets the owner name of this file

Returns:
the owner name or null if empty

getSize

public int getSize()
Gets the file size (in MBytes)

Returns:
the file size (in MBytes)

getSizeInByte

public int getSizeInByte()
Gets the file size (in bytes)

Returns:
the file size (in bytes)

setFileSize

public boolean setFileSize(int fileSize)
Sets the file size (in MBytes)

Parameters:
fileSize - the file size (in MBytes)
Returns:
true if successful, false otherwise

setUpdateTime

public boolean setUpdateTime(double time)
Sets the last update time of this file (in seconds)
NOTE: This time is relative to the start time. Preferably use GridSim.clock() method.

Parameters:
time - the last update time (in seconds)
Returns:
true if successful, false otherwise

getLastUpdateTime

public double getLastUpdateTime()
Gets the last update time (in seconds)

Returns:
the last update time (in seconds)

setRegistrationID

public boolean setRegistrationID(int id)
Sets the file registration ID (published by a Replica Catalogue entity)

Parameters:
id - registration ID
Returns:
true if successful, false otherwise

getRegistrationID

public int getRegistrationID()
Gets the file registration ID

Returns:
registration ID

setType

public boolean setType(int type)
Sets the file type (e.g. raw, tag, etc)

Parameters:
type - a file type
Returns:
true if successful, false otherwise

getType

public int getType()
Gets this file type

Returns:
file type

setChecksum

public boolean setChecksum(int checksum)
Sets the checksum of this file

Parameters:
checksum - the checksum of this file
Returns:
true if successful, false otherwise

getChecksum

public int getChecksum()
Gets the file checksum

Returns:
file checksum

setCost

public boolean setCost(double cost)
Sets the cost associated with this file

Parameters:
cost - cost of this file
Returns:
true if successful, false otherwise

getCost

public double getCost()
Gets the cost associated with this file

Returns:
the cost of this file

getCreationTime

public long getCreationTime()
Gets the file creation time (in millisecond)

Returns:
the file creation time (in millisecond)

isRegistered

public boolean isRegistered()
Checks if this file already registered to a Replica Catalogue

Returns:
true if it is registered, false otherwise

setMasterCopy

public void setMasterCopy(boolean masterCopy)
Marks this file as a master copy or replica

Parameters:
masterCopy - a flag denotes true for master copy or false for a replica

isMasterCopy

public boolean isMasterCopy()
Checks whether this file is a master copy or replica

Returns:
true if it is a master copy or false otherwise

setReadOnly

public void setReadOnly(boolean readOnly)
Marks this file as a read only or not

Parameters:
readOnly - a flag denotes true for read only or false for re-writeable

isReadOnly

public boolean isReadOnly()
Checks whether this file is a read only or not

Returns:
true if it is a read only or false otherwise

setTransactionTime

public boolean setTransactionTime(double time)
Sets the current transaction time (in second) of this file. This transaction time can be related to the operation of adding / deleting / getting this file on a resource's storage.

Parameters:
time - the transaction time (in second)
Returns:
true if successful, false otherwise
See Also:
Storage.addFile(File), Storage.addFile(List), Storage.addReservedFile(File), Storage.deleteFile(File), Storage.deleteFile(String), Storage.deleteFile(String, File), Storage.getFile(String), Storage.renameFile(File, String)

getTransactionTime

public double getTransactionTime()
Gets the last transaction time of this file (in second).

Returns:
the transaction time (in second)

GridSim 5.0 beta

The University of Melbourne, Australia, 2009