org.gcube.vremanagement.resourcemanager.impl.resources
Class ScopedResource

java.lang.Object
  extended by org.gcube.vremanagement.resourcemanager.impl.resources.ScopedResource
Direct Known Subclasses:
ScopedAnyResource, ScopedDeployedSoftware, ScopedGHN, ScopedRunningInstance

public abstract class ScopedResource
extends Object

An abstract model for a scoped GCUBEResource

Author:
Manuele Simi (ISTI-CNR)

Nested Class Summary
 class ScopedResource.ResourceNotFound
          Unable to find the resource in the infrastructure
static class ScopedResource.STATUS
          resource's legal statuses
 
Field Summary
protected  Operator.ACTION action
          the last action performed on the resource
protected  String errorMessage
          the error message, if any, from the last operation
protected  String hostedOn
          where the resource is hosted on, it makes sense for RI, GHN
protected  String id
          the resource identifier
protected  Date jointTime
          Last modification time stamp
protected  Date lastModificationTime
          Last modification time stamp
protected  org.gcube.common.core.utils.logging.GCUBELog logger
          Object getLogger()
protected  String scope
           
protected  ScopedResource.STATUS status
          the current status of the resource
protected  boolean success
          result of the last operation performed on the resource
protected  String type
          the resource type
 
Constructor Summary
ScopedResource(String id, String type, org.gcube.common.core.scope.GCUBEScope scope)
           
 
Method Summary
protected abstract  void addToScope()
          Adds the resource to the scope
 void doAction(Operator.ACTION action)
           
 boolean equals(Object obj)
          
protected abstract  void find()
          Custom
 void findResource()
          Looks for the resource in the infrastructure
 Operator.ACTION getAction()
           
 String getErrorMessage()
           
 String getHostedOn()
           
 String getId()
           
 Date getJointTime()
           
 Date getLastModificationTime()
           
protected  org.gcube.common.core.utils.logging.GCUBELog getLogger()
           
protected  int getMaxFindAttempts()
          Number of times the resource is searched in the IS before to declare it lost
 org.gcube.common.core.scope.GCUBEScope getScope()
           
 ScopedResource.STATUS getStatus()
           
 String getType()
           
 int hashCode()
          
 boolean isSuccess()
           
protected
<E extends Exception>
void
noHopeForMe(String message, E e)
          Gives up the operation on the resource
protected abstract  void removeFromScope()
          Removes the resource from the scope
 void setErrorMessage(String errorMessage)
           
 void setHostedON(String hostedOn)
           
 void setJointTime(Date time)
          Updates the time the resource joined the scope
 void setScope(org.gcube.common.core.scope.GCUBEScope scope)
           
 void setStatus(ScopedResource.STATUS status)
           
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected org.gcube.common.core.utils.logging.GCUBELog logger
Object getLogger()


id

protected String id
the resource identifier


type

protected String type
the resource type


hostedOn

protected String hostedOn
where the resource is hosted on, it makes sense for RI, GHN


success

protected boolean success
result of the last operation performed on the resource


errorMessage

protected String errorMessage
the error message, if any, from the last operation


scope

protected String scope

action

protected Operator.ACTION action
the last action performed on the resource


lastModificationTime

protected Date lastModificationTime
Last modification time stamp


jointTime

protected Date jointTime
Last modification time stamp


status

protected ScopedResource.STATUS status
the current status of the resource

Constructor Detail

ScopedResource

public ScopedResource(String id,
                      String type,
                      org.gcube.common.core.scope.GCUBEScope scope)
Method Detail

find

protected abstract void find()
                      throws Exception
Custom

Throws:
ScopedResource.ResourceNotFound - if it is impossible to locate the resource
Exception

findResource

public void findResource()
                  throws ScopedResource.ResourceNotFound
Looks for the resource in the infrastructure

Throws:
ScopedResource.ResourceNotFound - if it is impossible to locate the resource

doAction

public void doAction(Operator.ACTION action)
              throws ScopedResource.ResourceNotFound,
                     Exception
Throws:
ScopedResource.ResourceNotFound
Exception

addToScope

protected abstract void addToScope()
                            throws ScopedResource.ResourceNotFound,
                                   Exception
Adds the resource to the scope

Throws:
Exception - if the operation fails
ScopedResource.ResourceNotFound - if the resource does not exist in the infrastructure

removeFromScope

protected abstract void removeFromScope()
                                 throws ScopedResource.ResourceNotFound,
                                        Exception
Removes the resource from the scope

Throws:
Exception - if the operation fails
ScopedResource.ResourceNotFound - if the resource does not exist in the infrastructure

getId

public String getId()
Returns:
the resource ID

getType

public String getType()
Returns:
the resource type

getScope

public final org.gcube.common.core.scope.GCUBEScope getScope()
Returns:
the scope

setScope

public final void setScope(org.gcube.common.core.scope.GCUBEScope scope)

getAction

public Operator.ACTION getAction()
Returns:
the action

getErrorMessage

public String getErrorMessage()
Returns:
the errorMessage

setErrorMessage

public void setErrorMessage(String errorMessage)
Parameters:
errorMessage - the errorMessage to set

setJointTime

public void setJointTime(Date time)
Updates the time the resource joined the scope

Parameters:
time - the new joint time

isSuccess

public boolean isSuccess()
Returns:
the success

getHostedOn

public String getHostedOn()
Returns:
the node on which the Scope is hosted

setHostedON

public void setHostedON(String hostedOn)

getJointTime

public Date getJointTime()

getLastModificationTime

public Date getLastModificationTime()

getStatus

public ScopedResource.STATUS getStatus()
Returns:
the status

setStatus

public void setStatus(ScopedResource.STATUS status)
Parameters:
status - the status to set

getMaxFindAttempts

protected int getMaxFindAttempts()
Number of times the resource is searched in the IS before to declare it lost

Returns:

hashCode

public int hashCode()

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

noHopeForMe

protected <E extends Exception> void noHopeForMe(String message,
                                                 E e)
                    throws E extends Exception
Gives up the operation on the resource

Parameters:
message - the error message to return
e - the exception that generates the hopeless
Throws:
E - the source exception
E extends Exception

toString

public String toString()

Overrides:
toString in class Object

getLogger

protected org.gcube.common.core.utils.logging.GCUBELog getLogger()


Copyright © 2012. All Rights Reserved.