GridSim 5.0 beta

gridsim.parallel.reservation
Class ReservationMessage

Object
  extended by ReservationMessage

public class ReservationMessage
extends Object

This class represents a single message exchanged between users and a resource providers to negotiate an advance reservation.

Since:
5.0
Author:
Marcos Dias de Assuncao
See Also:
Reservation

Constructor Summary
ReservationMessage(int sourceId)
          Instantiates a new object.
ReservationMessage(int sourceId, int destId)
          Instantiates a new object.
ReservationMessage(int sourceId, int destId, Reservation reservation)
          Instantiates a new object.
ReservationMessage(int sourceId, Reservation reservation)
          Instantiates a new object.
 
Method Summary
 ReservationMessage createResponse()
          Creates a response for this message.
 int getDestinationID()
          Gets the destination ID
 ErrorType getErrorCode()
          Gets the error code of this message
 int getMessageID()
          Gets the message's ID
 int getMessageSize()
          Returns the size in bytes for this message.
 MessageType getMessageType()
          Gets the message's type
 int getNegotiationID()
          Gets the id of the reservation this message is related to
 double getPrice()
          Returns the price
 Reservation getReservation()
          Gets the reservation to which this message refers
 int getReservationID()
          Gets the ID of reservation to which this message refers
 int getSourceID()
          Gets the source id
 boolean setDestinationID(int destId)
          Sets the destination's id
 void setErrorCode(ErrorType code)
          Sets the error code of this message
 void setMessageType(MessageType type)
          Sets the message type
 boolean setPrice(double price)
          Sets the price negotiated
 boolean setSourceID(int sourceId)
          Sets the source's id
 String toString()
          Converts the negotiation message to a String.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReservationMessage

public ReservationMessage(int sourceId,
                          int destId)
Instantiates a new object.

Parameters:
sourceId - the id of entity that is the source of this message
destId - the id of the entity that is the recipient of this message
Throws:
IllegalArgumentException - is thrown if the IDs are < 0

ReservationMessage

public ReservationMessage(int sourceId)
Instantiates a new object.

Parameters:
sourceId - the id of entity that is the source of this message
Throws:
IllegalArgumentException - is thrown if the ID is < 0

ReservationMessage

public ReservationMessage(int sourceId,
                          Reservation reservation)
Instantiates a new object.

Parameters:
sourceId - the id of entity that is the source of this message
reservation - the reservation to which this message refers
Throws:
IllegalArgumentException - is thrown if the IDs are < 0 or the reservation object is null

ReservationMessage

public ReservationMessage(int sourceId,
                          int destId,
                          Reservation reservation)
Instantiates a new object.

Parameters:
sourceId - the id of entity that is the source of this message
destId - the id of the entity that is the recipient of this message
reservation - the reservation to which this message refers
Throws:
IllegalArgumentException - is thrown if the IDs are < 0 or the reservation object is null
Method Detail

setSourceID

public boolean setSourceID(int sourceId)
Sets the source's id

Parameters:
sourceId - the id of the source entity
Returns:
true if it has been set successfully; false otherwise

setDestinationID

public boolean setDestinationID(int destId)
Sets the destination's id

Parameters:
destId - the id of the destination entity
Returns:
true if it has been set successfully; false otherwise

setMessageType

public void setMessageType(MessageType type)
Sets the message type

Parameters:
type - the message type

setErrorCode

public void setErrorCode(ErrorType code)
Sets the error code of this message

Parameters:
code - the error code

getSourceID

public int getSourceID()
Gets the source id

Returns:
the source id

getDestinationID

public int getDestinationID()
Gets the destination ID

Returns:
the destination id

getMessageID

public int getMessageID()
Gets the message's ID

Returns:
the message's id

getMessageType

public MessageType getMessageType()
Gets the message's type

Returns:
the message's type

getErrorCode

public ErrorType getErrorCode()
Gets the error code of this message

Returns:
the error code of this message

getReservation

public Reservation getReservation()
Gets the reservation to which this message refers

Returns:
the reservation object

getReservationID

public int getReservationID()
Gets the ID of reservation to which this message refers

Returns:
the reservation id of -1 if not found

getNegotiationID

public int getNegotiationID()
Gets the id of the reservation this message is related to

Returns:
the reservation id or -1 if the reservation is unknown

setPrice

public boolean setPrice(double price)
Sets the price negotiated

Parameters:
price - the price negotiated
Returns:
true if successfully or false otherwise

getPrice

public double getPrice()
Returns the price

Returns:
price

getMessageSize

public int getMessageSize()
Returns the size in bytes for this message. NOTE: This is used to get network statistics

Returns:
the size in bytes of this message

createResponse

public ReservationMessage createResponse()
Creates a response for this message. This method creates a new message and sets the received of the message created as the sender of this message and the sender of the created message as the received of this message.

Returns:
the message created.

toString

public String toString()
Converts the negotiation message to a String. This method is used for debugging purposes

Overrides:
toString in class Object
Returns:
a String representing the negotiation message

GridSim 5.0 beta

The University of Melbourne, Australia, 2009