Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Project Rio
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jini.rio.core.provision
Class ServiceRecord

    java.lang.Object
      org.jini.rio.core.provision.ServiceRecord

All Implemented Interfaces:
  Serializable, Comparable

    public class ServiceRecord

extends Object
implements Comparable, Serializable

A ServiceRecord documents service instantiated time, discard time, where the service ran and contains `ResourceCost` information for system resources accessed during the service's execution

See Also:
  Serialized Form

Field Summary
`static int` | `ACTIVE_SERVICE_RECORD` Indicates a service which is currently active,
`static int` | `INACTIVE_SERVICE_RECORD` Specifies a service which has been discarded, is not longer active

Constructor Summary
`ServiceRecord(Uuid uuid, ServiceElement sElem, String hostName)` Create a ServiceRecord.
`ServiceRecord(Uuid uuid, ServiceElement sElem, String hostName, int type, Date instantiated)` Create a ServiceRecord.

Method Summary
`void` | `addResourceCost(ResourceCost resourceCost)` Add a ResourceCost
`int` | `compareTo(Object o)` Compares this ServiceRecord to another ServiceRecord with respect to the ServiceRecord instantiation Date.
`long` | `computeElapsedTime()` Compute the elapsed time the service has been active.
`boolean` | `equals(Object o)` A ServiceRecord is equal to another ServiceRecord if their Uuid's and instantiation Dates are equal
`Date` | `getDiscardedDate()`
`String` | `getHostName()`
`Date` | `getInstantiationDate()`
`String` | `getName()`
`ResourceCost[]` | `getResourceCosts()` Get the ResourceCost instances.
`ServiceElement` | `getServiceElement()`
`Uuid` | `getServiceID()` Get the uuid for the service
`int` | `getType()` Get the type of ServiceRecord
`Date` | `getUpdated()`
`int` | `hashCode()` Override hashCode to return the hashCode of the Uuid and the instantiated Date
`void` | `setDiscardedDate(Date discarded)`
`void` | `setType(int type)` Set the type of this record to be either `ACTIVE_SERVICE_RECORD` or `INACTIVE_SERVICE_RECORD`
`void` | `setUpdated()` Set that the ServiceRecord has been updated
`String` | `toString()`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### ACTIVE_SERVICE_RECORD

    public static final int ACTIVE_SERVICE_RECORD

  Indicates a service which is currently active,

  See Also:
    Constant Field Values

### INACTIVE_SERVICE_RECORD

    public static final int INACTIVE_SERVICE_RECORD

  Specifies a service which has been discarded, is not longer active

  See Also:
    Constant Field Values

Constructor Detail

### ServiceRecord

    public ServiceRecord(Uuid uuid,
                         ServiceElement sElem,
                         String hostName)

  Create a ServiceRecord. The `type` property is set to `ACTIVE_SERVICE_RECORD`, and the `instantiated` property set to the current Date

  Parameters:
    `uuid` - Unique ID of the service
    `sElem` - The ServiceElement
    `hostName` - The hostname of the compute resource the service is running on

### ServiceRecord

    public ServiceRecord(Uuid uuid,
                         ServiceElement sElem,
                         String hostName,
                         int type,
                         Date instantiated)

  Create a ServiceRecord. The `type` property is set to `ACTIVE_SERVICE_RECORD`, and the `instantiated` property set to the current Date

  Parameters:
    `uuid` - Unique ID of the service
    `sElem` - The ServiceElement
    `hostName` - The hostname of the compute resource the service is running on
    `type` - The type of the record
    `instantiated` - The Date the service has been instantiated

Method Detail

### getServiceID

    public Uuid getServiceID()

  Get the uuid for the service

  Returns:
    The unique ID for the service

### getName

    public String getName()

  Returns:
    The service name

### getHostName

    public String getHostName()

  Returns:
    The hostName

### setType

    public void setType(int type)

  Set the type of this record to be either `ACTIVE_SERVICE_RECORD` or `INACTIVE_SERVICE_RECORD`

  Parameters:
    `type` - The type of the ServiceRecord
  Throws:
    `IllegalArgumentException` - if the supplied type is neither `ACTIVE_SERVICE_RECORD` or `INACTIVE_SERVICE_RECORD`

### getType

    public int getType()

  Get the type of ServiceRecord

  Returns:
    `ACTIVE_SERVICE_RECORD` or `INACTIVE_SERVICE_RECORD`

### getInstantiationDate

    public Date getInstantiationDate()

  Returns:
    The `Date` the service was instantiated

### setUpdated

    public void setUpdated()

  Set that the ServiceRecord has been updated

### getUpdated

    public Date getUpdated()

  Returns:
    The Date that the ServiceRecord was been updated

### setDiscardedDate

    public void setDiscardedDate(Date discarded)

  Parameters:
    `discarded` - The `Date` the service was discarded

### getDiscardedDate

    public Date getDiscardedDate()

  Returns:
    The `Date` the service was discarded. If the service has not been discarded then this method will return `null`

### getServiceElement

    public ServiceElement getServiceElement()

  Returns:
    The ServiceElement object

### computeElapsedTime

    public long computeElapsedTime()

  Compute the elapsed time the service has been active. If the service is still active the value returned will be based on the current time

  Returns:
    The elapsed time (in milliseconds) the service has been instantiated

### addResourceCost

    public void addResourceCost(ResourceCost resourceCost)

  Add a ResourceCost

  Parameters:
    `resourceCost` - The ResourceCost to add. If the ResourceCost for a named resource alerady exists, it will be replaced

### getResourceCosts

    public ResourceCost[] getResourceCosts()

  Get the ResourceCost instances.

  Returns:
    An array of ResourceCost instances. A new array will be allocated each time. If there are no ResourceCost instances, an empty array will be returned.

### compareTo

    public int compareTo(Object o)

  Compares this ServiceRecord to another ServiceRecord with respect to the ServiceRecord instantiation Date.

  Specified by:
    `compareTo` in interface `Comparable`
  Parameters:
    `o` - The Object to be compared.
  Returns:
    A negative integer if this ServiceRecord has an instantiatedDate before the ServiceRecord being compared to, zero if the instantiatedDate property is equal, or a postive number if the instantiatedDate is later.

### equals

    public boolean equals(Object o)

  A ServiceRecord is equal to another ServiceRecord if their Uuid's and instantiation Dates are equal

  Overrides:
    `equals` in class `Object`

### hashCode

    public int hashCode()

  Override hashCode to return the hashCode of the Uuid and the instantiated Date

  Overrides:
    `hashCode` in class `Object`

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Project Rio
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © Project Rio.