org.gcube.vremanagement.resourcebroker.impl.support.types
Class GHNDescriptor

java.lang.Object
  extended by org.gcube.vremanagement.resourcebroker.impl.support.types.SortableElement<java.lang.Float,java.lang.String>
      extended by org.gcube.vremanagement.resourcebroker.impl.support.types.GHNDescriptor
All Implemented Interfaces:
java.lang.Comparable<SortableElement<java.lang.Float,java.lang.String>>

public class GHNDescriptor
extends SortableElement<java.lang.Float,java.lang.String>

Locally used to describe GHN. The only information needed to handle GHN that are useful to make decision planning are stored at this level.

Author:
Daniele Strollo (ISTI-CNR)

Constructor Summary
GHNDescriptor(int allocatedResources, java.lang.String elem, GCUBEScope scope, XMLResult profile)
          Creates a new GHNDescriptor that is sortable on the sortIdx value.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Compares two GHNDescriptor elems.
 float getAccuracy()
          Returns the actual score of a GHN.
 int getHits()
           
 java.lang.String getID()
           
 float getLoadLast15M()
           
 float getLoadLast1M()
           
 float getLoadLast5M()
           
 PlanBuilderIdentifier getOwner()
          Deprecated. for internal use only
 int getRICount()
           
 GCUBEScope getScope()
           
 java.lang.Float getScore()
           
 java.lang.Float getSortIndex()
          Differently from a generic SortableElement, here the sorting is based on the number of allocated resources plus the number of reserved ones.
 int hashCode()
           
 boolean hasProfile()
           
 void increaseRICount()
           
 boolean isReservableBy(PlanBuilderIdentifier wfID)
          Once reserved a GHN is uniquely associated to the plan that firstly reserved it.
 boolean isReserved()
          To check if a GHNDescriptor is reserved by someone.
 void registerScore(int score)
          Registers the new score hit by this GHN.
 void reserve(PlanBuilderIdentifier wfID)
          Deprecated. do not use this
 void revokeAllReservations(PlanBuilderIdentifier wfID)
          Forgets all previous reservations.
 void revokeReservation(PlanBuilderIdentifier wfID)
          Forgets a previous reservation.
 boolean satisfies(Requirement[] requirements)
          Given a list of Requirement elements checks if all these requirements are satisfied.
 void setProfile(XMLResult profile)
          Deprecated. for internal use only
 void setRICount(int allocatedResources)
          Used internally to update the number of RI associated to a GHN.
 
Methods inherited from class org.gcube.vremanagement.resourcebroker.impl.support.types.SortableElement
compareTo, getElement, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GHNDescriptor

public GHNDescriptor(int allocatedResources,
                     java.lang.String elem,
                     GCUBEScope scope,
                     XMLResult profile)
Creates a new GHNDescriptor that is sortable on the sortIdx value. The sortIdx corresponds to the "virtual" resources allocated on such nodes. Virtual is intended to represent the number of actual allocated resources plus the reserved ones. Each time a GHNDescriptor is assigned to a new plan it is automatically reserved so that it keeps track that a new resource will be potentially allocated on it. If the resource plan received a bad feedback or the reservation plan must be revoked, the retreateReservation must be called to forget the previous reservation request.

Parameters:
allocatedResources - the number of allocated resources. Used by SortableElement compare method.
elem - the ghn identifier.
Method Detail

reserve

public final void reserve(PlanBuilderIdentifier wfID)
Deprecated. do not use this

Keeps track of a new reservation for the current GHN.


isReservableBy

public final boolean isReservableBy(PlanBuilderIdentifier wfID)
Once reserved a GHN is uniquely associated to the plan that firstly reserved it. As consequence, it can be only reserved for the same plan.

Parameters:
wfID - the PlanBuilderIdentifier requiring the reservation.
Returns:
true if allowed to reserve the GHN.

getOwner

public final PlanBuilderIdentifier getOwner()
Deprecated. for internal use only


isReserved

public final boolean isReserved()
To check if a GHNDescriptor is reserved by someone.


revokeReservation

public final void revokeReservation(PlanBuilderIdentifier wfID)
Forgets a previous reservation.


revokeAllReservations

public final void revokeAllReservations(PlanBuilderIdentifier wfID)
Forgets all previous reservations.


getID

public final java.lang.String getID()
Returns:
the identifier of GHN

setRICount

public final void setRICount(int allocatedResources)
Used internally to update the number of RI associated to a GHN.

Parameters:
allocatedResources - the number of allocated RI.

getRICount

public final int getRICount()

increaseRICount

public final void increaseRICount()

getScope

public final GCUBEScope getScope()

getSortIndex

public final java.lang.Float getSortIndex()
Differently from a generic SortableElement, here the sorting is based on the number of allocated resources plus the number of reserved ones. Namely each GHN is sorted on the number of resource instances "virtually" allocated on them.

Overrides:
getSortIndex in class SortableElement<java.lang.Float,java.lang.String>

getScore

public final java.lang.Float getScore()

equals

public final boolean equals(java.lang.Object obj)
Compares two GHNDescriptor elems. The comparison is made on the unique ID of the GHN regardless the number of allocated resources of them. That is because it is assumed a single GHN descriptor present in the system at each time (or in the global queue of registered GHN retrieved from the IS or in the private queue of GHN reserved by a workflow). The compared GHNDescriptor elements must be in the same scope.

Overrides:
equals in class java.lang.Object

hashCode

public final int hashCode()
Overrides:
hashCode in class java.lang.Object

registerScore

public final void registerScore(int score)
Registers the new score hit by this GHN.

Parameters:
score - the percentage score reached (0..100).

getAccuracy

public final float getAccuracy()
Returns the actual score of a GHN.


getHits

public final int getHits()

setProfile

public final void setProfile(XMLResult profile)
Deprecated. for internal use only

Attaches to a GHN descriptor the XML part describing its internal features (the remotely stored profile). This part will be used to express requirements on GHNs.

Parameters:
profile -

hasProfile

public final boolean hasProfile()

satisfies

public final boolean satisfies(Requirement[] requirements)
                        throws GCUBEFault
Given a list of Requirement elements checks if all these requirements are satisfied.

Parameters:
requirements - an array of Requirement elements.
Returns:
true if all the requirements are satisfied or the requirements parameter is null or empty.
Throws:
GCUBEFault - if no profile is associated.

getLoadLast1M

public final float getLoadLast1M()

getLoadLast5M

public final float getLoadLast5M()

getLoadLast15M

public final float getLoadLast15M()