Difference between revisions of "Resource Manager"

From Gcube Wiki
Jump to: navigation, search
(Resource Report)
(Resource Report)
Line 67: Line 67:
 
   </Resources>
 
   </Resources>
 
   <DeploymentPlanCreation>
 
   <DeploymentPlanCreation>
       <!-- -->
+
       <!-- outcomes of the deployment plan creation -->
 
       <Status>SUCCESS / FAILED</Status>
 
       <Status>SUCCESS / FAILED</Status>
 
       <Message></Message>
 
       <Message></Message>

Revision as of 15:57, 20 May 2010

The Resource Manager service is in charge of managing gCube Scope contexts. An instance (and only one) of the service must be deployed for each scope (at any level, i.e. infrastructure, VO, VRE) in order to handle gCube Resources within the assigned scope. It manages requests of adding and removing gCube Resource from the assigned Scope by keeping, at the same time, a consistent state in the whole infrastructure. A Scope Resource is published in the Information System with constantly updated information about the current composition of the Scope.

Design

Service architecture and code design

The service implements a singleton WSRF pattern. This means that there is a single stateful resource holding the state of the managed Scope.

The following class diagram shows a simplified view of the organization and structure of the Resource Manager's source code.

Figure 1. Resource Manager Class Diagram

[TBD]

Concept, role and design of ScopedResource

A Resource Manager instance handles the Scope it is managing as a set of Scoped Resources. A Scoped Resource models a gCube Resource in a specific Scope. At the heart of the Scope management activities there is the management of the state of the Scoped Resources belonging the Scope.

The following diagram depicts the possible Scope Resource's statuses and the legal transitions among them. The starting point of the life of a Scope Resource is always the request to join an existing gCube Resource to the Scope.


Figure 2. Scoped Resource - life cycle

The crucial statuses are ADDED and REMOVED, where the concrete (and resource specific) actions to join the gCube Resource to the Scope are performed. For instance, in case of a Service Resource, a new instance of the service is deployed when managing the ADDED status, while undeployment is performed in the REMOVED status.

[TBC]


Scope state
  • Scope state management versus old VRE state management
  • Raw state separated from the state behavior to avoid mis-serializations due to any future change in the service implementation
  • Local XStream serialization
  • Synchronization between local and remote (i.e. stored in the IS) state and vice versa
  • ...

[TBC]

Observer pattern strategy

The service adopts an observer pattern-based internal strategy for managing the scope state. Each time the state of any Scoped Resource changes, registered observers are properly notified in order to manage the new state.

[TBC]

Interface

Resource Report

All the resource management requests work in an asynchronous manner. They return a report ID that can be used to query the getReport operation in order to retrieve a report of the activities performed. The basic structure of the report is:

<ResourceReport>
  <ID><!--report ID --></ID>
  <LastUpdate><!--last update time --></LastUpdate>
  <TargetScope><!-- target scope of the operations reported in the following section --></TargetScope>
  <Resources>
     <!-- list of gCube resources involved and their actual status-->  
     <Resource>
      <ID>..</ID>
      <Type>...</Type>
      <Status>ADDED/REMOVED/FAILED</Status>
    </Resource>
     <Resource>
      <ID>..</ID>
      <Type>...</Type>
      <Status>ADDED/REMOVED/FAILED</Status>
    </Resource>
  </Resources>
  <DeploymentPlanCreation>
      <!-- outcomes of the deployment plan creation -->
      <Status>SUCCESS / FAILED</Status>
      <Message></Message>
   </DeploymentPlanCreation>
  <Services>
   <!-- per each service involved in the request, a section like the following-->
    <Service>
 
     <!-- service data --> 
 
     <DependenciesResolution>
 
     <!-- information about service's dependencies (missed, resolved))-->
 
     </DependenciesResolution>
     <DeploymentActivity> or <UndeploymentActivity>
 
     <!-- information about (un)deployment activities on the target gHN-->
 
     </DeploymentActivity> or </UndeploymentActivity>
    <Service>
  </Services>
</ResourceReport>

The Services' section is reported in case that the activities performed involve the deployment or undeployment of services within the scope. For each service, information about the service's dependencies resolution (if any) and package deployment/undeployment are reported.

Possible dependencies statuses are:

  • SUCCESS: all the dependencies have been successfully resolved
  • FAILED: some dependencies are missing

Periodically, the Deployer service sends a report on the deployment activity (performed asynchronously with respect to the VREManager request). Such report has a status:

  • OPEN: the activity is still ongoing, other reports will follow
  • CLOSED : the activity is closed, no further report will be sent

Possible package statuses are:

  • WAITING: request is still pending
  • ALREADYDEPLOYED: the package was already available on the target gHN
  • SKIPPED: the package was not deployed due to an error in another service from which it depends on
  • FAILED: the deployment failed
  • DEPLOYED: the package has been deployed
  • NOTVERIFIED: the package has been deployed, but the correctness of the operation cannot be checked (and therefore guaranteed)
  • ACTIVATED: the package has been activated
  • RUNNING: the related instance is running

Possible resource statuses:

  • ADDED: the resource was successfully added to the scope
  • REMOVED: the resource was successfully removed to the scope
  • FAILED: an error occurred and the resource has not been managed

This is a sample report showing the results of a request to add 2 services, a generic resource, a collection, a metadata collection and an existing running instance to the managed scope.

Operations

The service exposes a single ResourceManager portType ...

[TBC]


Set/change the scope options

A number of options can be set on a scope by invoking the ChangeScopeOptions operation. Actually, the following properties are accepted:

  • Designer: the designer of the scope
  • Creator: the creator of the scope
  • StartTime: the activation time of the scope (accepted format is yyyy-MM-dd'T'HH:mm:ssZ, example: 2008-11-11T16:58:12+01:00)
  • EndTime: the last time of the scope (accepted format is yyyy-MM-dd'T'HH:mm:ssZ, example: 2008-11-11T16:58:12+01:00)
  • Description: a scope description
  • DisplayName: a name to display in any GUI
  • SecurityEnabled: a boolean flag to set up a secure or non-secure Scope

All of them are optionals and they can be set/updated any time, even if for some of them (like changing the start time once the scope is activated) such an action do not have any effect.


The ChangeScopeOptions operation can be invoked as follows:

import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.OptionsParameters;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ScopeOption;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceManagerPortType;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.service.ResourceManagerServiceAddressingLocator;
 
//...
 
protected static String[] optionNames = new String[] {"creator", "designer", "endTime", "startTime", 
			"description", "displayName", "securityenabled"};
//...
EndpointReferenceType endpoint = new EndpointReferenceType();
ResourceManagerPortType pt;	
try {
	endpoint.setAddress(new Address("http://"+ <ResourceManager host>+":"+ <ResourceManager port> +"/wsrf/services/gcube/vremanagement/ResourceManager"));
 
	GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() {  
					public boolean isSecurityEnabled() {return false;}};
	pt = GCUBERemotePortTypeContext.getProxy(new ResourceManagerServiceAddressingLocator().getResourceManagerPortTypePort(endpoint), 
							GCUBEScope.getScope(<caller scope>),managerSec);	
	OptionsParameters options = new OptionsParameters();
	ScopeOption[] scopeOptionList = new ScopeOption[optionNames.length];
	for (int i=0; i < optionNames.length; i++) 
		scopeOptionList[i] = new ScopeOption(optionNames[i], <PROPERTY VALUE>);
 
	options.setScopeOptionList(scopeOptionList);
	pt.changeScopeOptions(options);
} catch (Exception e) {
	//manage the error
}
Request to join a resource to the scope

A request to join a GCUBEResource to the VREManager scope is performed through the AddResources operation. For each resource there are two main information to provide:

  • the resource identifier
  • the resource type (must be one of: GHN, RunningInstance, Collection, MetadataCollection, GenericResource)

The AddResources operation can be invoked as follows:

import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.AddResourcesParameters;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceItem;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceList;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ServiceItem;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ServiceList;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceManagerPortType;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.service.ResourceManagerServiceAddressingLocator;
 
//...
 
EndpointReferenceType endpoint = new EndpointReferenceType();
 
try {
	endpoint.setAddress(new Address("http://"+ <ResourceManager host>+":"+ <ResourceManager port> +"/wsrf/services/gcube/vremanagement/ResourceManager"));
 
	GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() {  
					public boolean isSecurityEnabled() {return false;}
	};
	ResourceManagerPortType pt = GCUBERemotePortTypeContext.getProxy(new ResourceManagerServiceAddressingLocator().getResourceManagerPortTypePort(endpoint), 
		GCUBEScope.getScope(<callerScope>),managerSec);
 
	AddResourcesParameters add = new AddResourcesParameters();
 
	ResourceItem[] resourcelist = new ResourceItem[3];
	for (int i = 1 ; i < (resourcelist.length +1); i++) {
		resourcelist[i-1] = new ResourceItem();
		resourcelist[i-1].setID(<id>);
		resourcelist[i-1].setType(<resource type>);
	}
	ResourceList r = new ResourceList();
	r.setResource(resourcelist);
	add.setResources(r);
	add.setTargetScope(resources.getProperty("targetScope"));
	logger.info("Sending the Resource request....");
	String reportID = pt.addResources(add);
	logger.info("Returned report ID: " + reportID);
 
} catch (Exception e) {
	//manage the error
}
Request to remove a resource from the scope
Request to deploy a new service in the scope
Request to remove a Running Instance from the scope

There are two ways to obtain the removal of a Running Instance from a scope:

  • request the removal of th RI from the scope, in this case the RI is removed from the scope and, IF this was the only scope to which it was joined to, the RI is also undeployed from the target gHN.
  • request the undeployment of the related service from the scope, this will force all the RIs of the service to be undeployed from the scope, regardless any other condition (e.g. sharing with other scopes);

Whether way is used, the undeployment works only if the Running Instance was originally deployed within this scope (and not joined from another one), i.e. by the Resource Manager instance that is contacted.

Removing a Running Instance from the scope


This is the recommended in the light of maintaining consistencies among the scopes. The RI is undeployed only if it is not shared across multiple scopes.

import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.RemoveResourcesParameters;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceItem;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceList;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceManagerPortType;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.service.ResourceManagerServiceAddressingLocator;
import org.gcube.common.core.resources.GCUBERunningInstance;
 
 
EndpointReferenceType endpoint = new EndpointReferenceType();
 
try {
	//create the port-type
	endpoint.setAddress(new Address("http://"+ args[0]+":"+ args[1] +"/wsrf/services/gcube/vremanagement/ResourceManager"));
	GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() {  
	public boolean isSecurityEnabled() {return false;}};
	ResourceManagerPortType pt = GCUBERemotePortTypeContext.getProxy(new ResourceManagerServiceAddressingLocator().getResourceManagerPortTypePort(endpoint), 
		GCUBEScope.getScope(<caller Scope>),managerSec);
 
	//prepare the parameters
	RemoveResourcesParameters params = new RemoveResourcesParameters();
	ResourceItem[] resourcelist = new ResourceItem[1];
	resourcelist[0] = new ResourceItem();
	resourcelist[0].setID(<ID>);
	resourcelist[0].setType(GCUBERunningInstance.TYPE);
	ResourceList r = new ResourceList();
	r.setResource(resourcelist);
	params.setResources(r);
	params.setTargetScope("<target Scope>");
 
	//sending the request
	logger.info ("Sending the Remove Resource request....");
	String reportID = pt.removeResources(params);
	logger.info ("Returned report ID: " + reportID);
 
} catch (Exception e) {
        logger.error ("Failed to remove the RI ", e);
}

This is a sample report returned by invoking the RemoveResources with one or more RIs that was then undeployed.

Undeploy a Service from the scope


By requesting the undeployment of a service, all the instances of that service belonging the current scope will be undeployed. If they belong to multiple scopes, they will result as LOST resources there.

import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.RemoveResourcesParameters;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceManagerPortType;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ServiceItem;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ServiceList;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.service.ResourceManagerServiceAddressingLocator;
 
EndpointReferenceType endpoint = new EndpointReferenceType();
 
try {
	//create the port-type
	endpoint.setAddress(new Address("http://"+ args[0]+":"+ args[1] +"/wsrf/services/gcube/vremanagement/ResourceManager"));
	GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() {  
	public boolean isSecurityEnabled() {return false;}};
	ResourceManagerPortType pt = GCUBERemotePortTypeContext.getProxy(new ResourceManagerServiceAddressingLocator().getResourceManagerPortTypePort(endpoint), 
					GCUBEScope.getScope(<caller scope>),managerSec);
	//prepare the parameters
	RemoveResourcesParameters params = new RemoveResourcesParameters();
	ServiceItem[] servicelist = new ServiceItem[1];
	servicelist[0] = new ServiceItem();
	servicelist[0].setServiceClass(<Service Class>);
	servicelist[0].setServiceName(<Service Name>);
	servicelist[0].setServiceVersion(<Service Version>);
	ServiceList l = new ServiceList();
	l.setService(servicelist);
	params.setServices(l);	
	params.setTargetScope(<target Scope>);
 
	//sending the request
	logger.info ("Sending the Remove Resource request....");
	String reportID = pt.removeResources(params);
	logger.info ("Returned report ID: " + reportID);
 
 
} catch (Exception e) {
	logger.error("Failed to undeploy the Service",e);
}

[TBC]

Scope Resource

The Scope Resource is a view on the current composition of the Scope context published in the IS. Each time the Scope is modified, the view is updated.

[Describe the structure here]

Here is an example of Scope Resource published in the IS:

gHNManager integration

...

Deployer integration

...

Resource Broker integration

...

Test-suite and sample usages

The Resource Manager comes with a test-suite package allowing to test its functionalities.The test-suite is completely independent and does not require any other gCube package, except than a local gCore installation. The package is composed by a set of classes, sample configuration files and scripts ready to be executed.


|-lib
|--org.gcube.vremanagement.resourcemanager.testsuite.jar
|
|-samples
|---...
|
|-addresource.sh
|-getreport.sh
|-changescopeoptions.sh
|-...

Each script allows to test a different service's operation or group of operations logically related. In the following, an explanation of each script and its usage is provided.

Add Resource(s)

The AddResources script invokes the AddResources operation to add new GCUBEResources on a scope. It must be executed as follows

./addresource.sh <ResourceManager host> <ResourceManager port> <configuration file>

Clearly, the Resource Manager host and port are the information needed to contact the Resource Manager instance, while the configuration file reports the information about the resources to add or create and the scope in which they have to be managed.

This is an example of configuration file requesting to add 4 gCube Resources to the Scope /gcube/devsec/CNR-VRE:

#global properties
 
numOfServicesToAdd=0
numOfResourcesToAdd=4
targetScope=/gcube/devsec/CNR-VRE
callerScope=/gcube/devsec/CNR-VRE
 
# resources' list
resource.1.id=9ad3ce60-27aa-11df-9df7-e0bf8afcd20f
resource.1.type=Collection
resource.2.id=6e6e2ce0-1ca5-11df-a0fe-c8f6680864ab
resource.2.type=RunningInstance
resource.3.id=a5db71f0-27aa-11df-8ee2-c1a4489ea34b
resource.3.type=MetadataCollection
resource.4.id=df899630-82ae-11de-a6cc-f15c9cf886be
resource.4.type=GenericResource

If everything works, the following report is produced (it can be retrieved via the getReport script):

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ResourceReport>
  <ID>bdffb830-33a4-11df-97f6-8d3129726fea</ID>
  <LastUpdate>2010-03-19T18:14:10-04:00</LastUpdate>
  <TargetScope>/gcube/devsec/CNR-VRE</TargetScope>
  <Resources>
    <Resource>
      <ID>a5db71f0-27aa-11df-8ee2-c1a4489ea34b</ID>
      <Type>MetadataCollection</Type>
      <Status>ADDED</Status>
      <ErrorDescription>-</ErrorDescription>
    </Resource>
    <Resource>
      <ID>6e6e2ce0-1ca5-11df-a0fe-c8f6680864ab</ID>
      <Type>RunningInstance</Type>
      <Status>ADDED</Status>
      <ErrorDescription>-</ErrorDescription>
    </Resource>
    <Resource>
      <ID>df899630-82ae-11de-a6cc-f15c9cf886be</ID>
      <Type>GenericResource</Type>
      <Status>ADDED</Status>
      <ErrorDescription>-</ErrorDescription>
    </Resource>
    <Resource>
      <ID>9ad3ce60-27aa-11df-9df7-e0bf8afcd20f</ID>
      <Type>Collection</Type>
      <Status>ADDED</Status>
      <ErrorDescription>-</ErrorDescription>
    </Resource>
  </Resources>
  <Services/>
</ResourceReport>
Remove Resource(s)

The RemoveResources script invokes the RemoveResources operation to remove GCUBEResources from a scope. It must be executed as follows

./removeresource.sh <ResourceManager host> <ResourceManager port> <configuration file>

This is an example of configuration file requesting to remove a Collection from the Scope /gcube/devsec/CNR-VRE:

#global properties
numOfServicesToRemove=0
numOfResourcesToRemove=1
targetScope=/gcube/devsec/CNR-VRE
callerScope=/gcube/devsec/CNR-VRE
 
# resources' list
resource.1.id=9ad3ce60-27aa-11df-9df7-e0bf8afcd20f
resource.1.type=Collection

If everything works, the following report is produced (it can be retrieved via the getReport script):

<?xml version="1.0" encoding="UTF-8"?>
<ResourceReport>
  <ID>cfb41e90-3863-11df-9bfb-cfdb92619067</ID>
  <LastUpdate>2010-03-26T00:11:58+01:00</LastUpdate>
  <TargetScope>/gcube/devsec/CNR-VRE</TargetScope>
  <Resources>
    <Resource>
      <ID>9ad3ce60-27aa-11df-9df7-e0bf8afcd20f</ID>
      <Type>Collection</Type>
      <Status>REMOVED</Status>
    </Resource>
  </Resources>
  <Services/>
</ResourceReport>
Create a new Scope

The CreateScope script invokes the CreateScope operation in order to initialise a new Scope and assign to it the first set of gCube resources. It must be executed as follows

./createScope.sh <ResourceManager host> <ResourceManager port> <configuration file>

This is an example of configuration file requesting to

  • create a new VRE (named /gcube/devsec/CNR-VRE)with the indicated options
  • add to it 4 existing gCube Resources
  • deploy 2 new Services in the new Scope
######################################
# Sample VRE creation - properties file
######################################
 
targetScope=/gcube/devsec/CNR-VRE
callerScope=/gcube/devsec/CNR-VRE
 
#Scope properties
creator=CN=Manuele Simi, L=NMIS-ISTI, OU=Personal Certificate, O=INFN, C=IT
designer=CN=Manuele Simi, L=NMIS-ISTI, OU=Personal Certificate, O=INFN, C=IT
securityenabled=false
displayName=CNR-VRE
description=Sample VRE for testing purposes
 
#Scope resources
numOfServicesToAdd=2
numOfResourcesToAdd=4
 
# resources' list
resource.1.id=9ad3ce60-27aa-11df-9df7-e0bf8afcd20f
resource.1.type=Collection
resource.2.id=6e6e2ce0-1ca5-11df-a0fe-c8f6680864ab
resource.2.type=RunningInstance
resource.3.id=a5db71f0-27aa-11df-8ee2-c1a4489ea34b
resource.3.type=MetadataCollection
resource.4.id=df899630-82ae-11de-a6cc-f15c9cf886be
resource.4.type=GenericResource
 
# services' list
service.1.name=MetadataManager
service.1.class=MetadataManagement
service.1.version=1.00.00
service.2.name=XMLIndexer
service.2.class=MetadataManagement
service.2.version=1.00.00
 
#GHN IDs on which the service will be deployed
GHNSet=84c3aa10-3857-11df-b245-cbf0ea5a1843,05921df0-382d-11df-8c8f-f5ea2a36aefa
Dispose an existing Scope

[TDP]

Get Report

The GetReport script invokes the GetReport operation to retrieve a Resource Report. It must be executed as follows

./getreport.sh <ResourceManager host> <ResourceManager port> <caller scope> <report ID>

This request will print out the resource report related to the given report ID.