VRE Manager

From Gcube Wiki
Revision as of 18:45, 19 December 2008 by Manuele.simi (Talk | contribs) (Request to join a resource to the scope)

Jump to: navigation, search

The VREManager is a gCube Service offering the facilities for managing the constituents of the VREs, namely the service instances. It is the service in charge to coordinate the overall deployment and operation of each VRE.

Design

Within the gCube architecture, the VREManager is placed at the top of a stack of the VREManagement services, below only the VRE Modeler service. Each instance of the service is devoted to manage one and only one specific scope and, within such a scope, it is in charge of adding/updating/removing GCUBEResource. For a detailed explanation about what is a scope and what is in scope, check the Scope Management section of the gCore Developer Guide.


The VREManager adopts the Singleton pattern and it exposes a single port-type, gcube/vremanagement/vremanager/VREManager. Clients may manipulate GCUBEResources within the scope and get back information about what's going on by using the operations of such a port-type.

Manipulating a resource means to add or remove it from the scope managed by the VREManager instance. Howvere, there is one exception: the service resource. This type of resource represents a bunch of packages stored in the Software Repository ready to be deployed. When a client asks to the VREManager to add a service to its scope, the VREManager creates a new instance of that service and joins such an instance to its scope.

Interface

The operations exposed by the VREManager port-type are:

  • AddResources - the AddResources operation allows to add one or more resources to the managed Scope. Depending on the type of the resource, a range of different actions is started after its invocation.
  • RemoveResources - the RemoveResources operation is the counterpart of the AddResources. It removes from the managed Scope a set of GCUBEResources.
  • GetReport - this operation permits to access the Resource Report produced by either the two previous operations
  • SendReport - this operation is invoked by the Deployer Services to send the Deployment Report
  • SetScopeOptions - this operation can be used to change some options related to the current scope management

The public interface of the VREManager port-type can be found here.

Requesting a deployment

A request to deploy new service instances within the VREManager scope is performed through the AddResources operation. There are two main information to provide:

  • the list of services to deploy
  • the target GHNs

The former must be specified by populating the ServiceList object defined in the WSDL interface. Rather, there are several options to define the GHNs on which the deployment is done:

  1. to provide a GHN per each service
  2. to provide a list of GHNs for all the services
  3. to provide an empty list

In the case number 1., the deployment of the related service is always tried on the given GHN. In the case number 2., the service tries to find out the best allocation of the services by minimizing the required deployment operation and optimizing the services' distribution. In the last case, the deployments are performed by taking into account the current GHNs available in the scope. The first twos can be combined, by forcing some deployments on specific GHNs, and leaving the others to be decided by the VREManager. Sample Usage


The AddResource operation to request a deployment can be invoked as follows:

...
import org.gcube.vremanagement.vremanager.stubs.vremanager.AddResourcesParameters;
import org.gcube.vremanagement.vremanager.stubs.vremanager.ServiceItem;
import org.gcube.vremanagement.vremanager.stubs.vremanager.ServiceList;
import org.gcube.vremanagement.vremanager.stubs.vremanager.VREManagerPortType;
import org.gcube.vremanagement.vremanager.stubs.vremanager.service.VREManagerServiceAddressingLocator;
...

EndpointReferenceType endpoint = new EndpointReferenceType();
		
try {
	endpoint.setAddress(new Address("http://"+ <VREManager hostname>+":"+ <VREManager port> +"/wsrf/services/gcube/vremanagement/VREManager"));
	VREManagerPortType pt;

	GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() {  
		public boolean isSecurityEnabled() {return false;}};
	pt = GCUBERemotePortTypeContext.getProxy(new VREManagerServiceAddressingLocator().getVREManagerPortTypePort(endpoint), 
	GCUBEScope.getScope(...,managerSec);
					
	AddResourcesParameters add = new AddResourcesParameters();	
	ServiceItem[] servicelist = new ServiceItem[2];
	for (int i = 1 ; i < 2; i++) {
		servicelist[i-1] = new ServiceItem();
		servicelist[i-1].setServiceClass(...);
		servicelist[i-1].setServiceName(...);
		servicelist[i-1].setServiceVersion(...);
		servicelist[i-1].setGHN(...); //forces target gHN for the service
	}
			
	ServiceList l = new ServiceList();
	l.setService(servicelist);
	add.setServices(l);
	pt.addResources(add);
} catch (Exception e) {
	//managing the error
}

In the example above, the target gHN for each service is explicitly set. If one wants to let the VREManager to decide on which gHN to deploy the input services, it suffices to do not pass a GHN per ServiceItem, but to set a gHNs list in the ServiceList object, like in the following example:

	String ghns = "GHN1ID,GHN2ID,GHN3ID,GHN4ID,GHN5ID"
	ServiceList l = new ServiceList();
	l.setService(servicelist);
	l.setGHN(ghns);

The list of GHNs must be a comma-separated list of GHN IDs.

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 (e.g. GHN, RunningInstance, Collection, etc)

Usage example:

	ResourceItem[] resourcelist = new ResourceItem[new Integer(resources.getProperty("numOfResourcesToAdd"))];
	for (int i = 1 ; i < (resourcelist.length +1); i++) {
		resourcelist[i-1] = new ResourceItem();
		resourcelist[i-1].setID(resources.getProperty("resource." + i + ".id"));
		resourcelist[i-1].setType(resources.getProperty("resource." + i + ".type"));
	}
	ResourceList r = new ResourceList();
	r.setResource(resourcelist);
	add.setResources(r);
	System.out.println ("Sending the Resource request....");
	String reportID = pt.addResources(add);
	System.out.println ("Returned report ID: " + reportID);
Getting the Resources Report

The GetReport operation can be invoked as follows:


import org.gcube.vremanagement.vremanager.stubs.vremanager.VREManagerPortType;
import org.gcube.vremanagement.vremanager.stubs.vremanager.service.VREManagerServiceAddressingLocator;

...
		
EndpointReferenceType endpoint = new EndpointReferenceType();
		
try {
	endpoint.setAddress(new Address("http://"+ <VREManager hostname>+":"+ <VREManager port> +"/wsrf/services/gcube/vremanagement/VREManager"));
	GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() {  
			public boolean isSecurityEnabled() {return false;}};
	VREManagerPortType pt = GCUBERemotePortTypeContext.getProxy(new VREManagerServiceAddressingLocator().getVREManagerPortTypePort(endpoint), 
	GCUBEScope.getScope(...),managerSec);
	String report = pt.getReport(<Report ID >);
	System.out.println (report);
} catch (Exception e) {
	//manage the error
}
Setting the scope options

A number of options can be set on a scope by invoking the SetScopeOptions oepration. 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 VRE

All of them are optionals and, in the current version of the VREManager, they make sense only in a VRE scope. Moreover 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.

Sample Usage


The SetScopeOptions operation can be invoked as follows:

import org.gcube.vremanagement.vremanager.stubs.vremanager.VREManagerPortType;
import org.gcube.vremanagement.vremanager.stubs.vremanager.service.VREManagerServiceAddressingLocator;

...
protected static String[] optionNames = new String[] {"creator", "designer", "endTime", "startTime", 
			"description", "displayName", "securityenabled"};
		
EndpointReferenceType endpoint = new EndpointReferenceType();
try {
	endpoint.setAddress(new Address("http://"+ args[0]+":"+ args[1] +"/wsrf/services/gcube/vremanagement/VREManager"));
	GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() {  
					public boolean isSecurityEnabled() {return false;}};
	VREManagerPortType pt = GCUBERemotePortTypeContext.getProxy(new VREManagerServiceAddressingLocator().getVREManagerPortTypePort(endpoint), 
							GCUBEScope.getScope(resources.getProperty("callerScope")),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.setScopeOptions(options);
			
} catch (Exception e) {
	//manage the error
}

State

The Service publishes its state into the IS modelled as a Generic Resource. Such a state is a picture of the set of GCUBEResources joining the managed scope.

The following is a sample serialization of the state taken when the managed scope is composed by 3 running instances and 1 content collection:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Resource>
  <ID>f66c6af0-b26e-11dd-b52d-a0a66b833425</ID>
  <Type>GenericResource</Type>
  <Scopes>
    <Scope>/gcube/devsec/BigBang</Scope>
  </Scopes>
  <Profile>
    <SecondaryType>VRE</SecondaryType>
    <Name>BigBangVRE</Name>
    <Description>secondVRE</Description>
    <Body>
      <Scope>/gcube/devsec/BigBang</Scope>
      <Service>http://dlib33.isti.cnr.it:8002/wsrf/services/gcube/vremanagement/VREManager</Service>
      <Creator>CN=Manuele Simi, L=NMIS-ISTI, OU=Personal Certificate, O=INFN, C=IT</Creator>
      <Designer>CN=Manuele Simi, L=NMIS-ISTI, OU=Personal Certificate, O=INFN, C=IT</Designer>
      <StartTime>2008-11-14T18:09:14+01:00</StartTime>
      <SecurityEnabled>false</SecurityEnabled>
      <ScopedRescources>
        <ScopedRescource>
          <ResourceID>af4ede50-b28c-11dd-9f37-e238d9877c06</ResourceID>
          <ResourceType>RunningInstance</ResourceType>
          <HostedOn>dlib33.isti.cnr.it:8001</HostedOn>
        </ScopedRescource>
        <ScopedRescource>
          <ResourceID>4a2eca60-b293-11dd-8c95-9a3d3d893fb0</ResourceID>
          <ResourceType>RunningInstance</ResourceType>
          <HostedOn>dlib33.isti.cnr.it:8001</HostedOn>
        </ScopedRescource>
        <ScopedRescource>
          <ResourceID>2fc77e50-b294-11dd-80a0-f5a49621b0ea</ResourceID>
          <ResourceType>RunningInstance</ResourceType>
          <HostedOn>dlib16.isti.cnr.it:8080</HostedOn>
        </ScopedRescource>
        <ScopedRescource>
          <ResourceID>f66c6af0-b26e-11dd-b52d-a0a66b833425</ResourceID>
          <ResourceType>Collection</ResourceType>
        </ScopedRescource>
      </ScopedRescources>
    </Body>
  </Profile>
</Resource>

The state of the VREManager is serialized either in the IS and locally on the file system. At startup time the instance looks for the local serialization and, in case it is not found, it queries the IS to retrieve its state. The local serialization is in the <gCore location>/etc/org.gcube.vremanagement.vremanager/scopeMap.xml.

Resource Report

After each resource management request, a report is produced and disseminated.

For each service, information about the service's dependencies resolution and package deployment are reported.

Possible dependencies states 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 state:

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

Possible package states 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
  • ACTIVATED: the package has been activated
  • RUNNING: the related instance is running

Possible resource states:

  • 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 including the add of a service, a generic resource, a collection and an existing running instance to the managed scope:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ResourceReport>
  <ID>4522f7c0-a54c-11dd-8525-e7e836b0fdde</ID>
  <LastUpdate>2008-10-29T00:58:17+01:00</LastUpdate>
  <TargetScope>/gcube/devsec</TargetScope>
  <Services>
    <Service>
      <Class>InformationSystem</Class>
      <Name>IS-Notifier</Name>
      <Version>1.00.00</Version>
      <DependenciesResolutionStatus>SUCCESS</DependenciesResolutionStatus>
      <DeployedOn>9bf172d0-a30c-11dd-88bf-83f7edc13611</DeployedOn>
      <ErrorDescription>-</ErrorDescription>
      <DependenciesResolution>
        <ResolvedDependencies>
          <Dependency>
            <ServiceClass>InformationSystem</ServiceClass>
            <ServiceName>IS-Notifier</ServiceName>
            <ServiceVersion>1.00.00</ServiceVersion>
            <PackageName>Notifier-service</PackageName>
            <PackageVersion>1.01.00</PackageVersion>
          </Dependency>
          <Dependency>
            <ServiceClass>InformationSystem</ServiceClass>
            <ServiceName>IS-Notifier</ServiceName>
            <ServiceVersion>1.00.00</ServiceVersion>
            <PackageName>Notifier-stubs</PackageName>
            <PackageVersion>1.00.01</PackageVersion>
          </Dependency>
        </ResolvedDependencies>
        <MissingDependencies/>
      </DependenciesResolution>
    </Service>
  </Services>
  <DeploymentActivity>
    <GHN>
      <Host>dlib33.isti.cnr.it:8001</Host>
      <ID>9bf172d0-a30c-11dd-88bf-83f7edc13611</ID>
      <LastReportReceivedOn>2008-10-29T00:58:16+01:00</LastReportReceivedOn>
      <LastReportReceived>
        <Status>OPEN</Status>
        <Packages>
          <Package>
            <ServiceClass>InformationSystem</ServiceClass>
            <ServiceName>IS-Notifier</ServiceName>
            <ServiceVersion>1.00.00</ServiceVersion>
            <PackageName>Notifier-service</PackageName>
            <PackageVersion>1.01.00</PackageVersion>
            <Status>RUNNING</Status>
            <Message>The package has NOT been successfully deployed. Possible cause: unable to deploy because of a RI of the service is already deployed on this node</Message>
          </Package>
          <Package>
            <ServiceClass>InformationSystem</ServiceClass>
            <ServiceName>IS-Notifier</ServiceName>
            <ServiceVersion>1.00.00</ServiceVersion>
            <PackageName>Notifier-stubs</PackageName>
            <PackageVersion>1.00.01</PackageVersion>
            <Status>ACTIVATED</Status>
            <Message>The package could not be deployed because it depends on a package which has an error</Message>
          </Package>
        </Packages>
      </LastReportReceived>
    </GHN>
  </DeploymentActivity>
  <Resources>
    <Resource>
      <ID>83080450-a235-11dd-8a29-b025e02401d5</ID>
      <Type>RunningInstance</Type>
      <Status>ADDED</Status>
      <ErrorDescription>-</ErrorDescription>
    </Resource>
    <Resource>
        <ID>61927680-a996-11dd-961c-8eba14a244c3</ID>
        <Type>MetadataCollection</Type>
        <Status>ADDED</Status>
        <ErrorDescription>-</ErrorDescription>
    </Resource>
    <Resource>
        <ID>f2c04460-b446-11dd-8aab-e7a1e3fdae89</ID>
        <Type>GenericResource</Type>
        <Status>ADDED</Status>
        <ErrorDescription>-</ErrorDescription>
    </Resource>
  </Resources>
</ResourceReport>

Configuration

The only configuration parameter is the Scope in which the instance has to operate in. This can be specified in two ways:

  • as static start Scope of the RI (see the releate section on the gCore Developer Guide for details);
  • as deployment parameter, in case the VREManager itself is dynamically deployed trough the Deployer facilities.

The test-suite

The VREManager 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.vremanager.testsuite.jar
|
|-samples
|---...
|
|-addresource.sh
|-getreport.sh
|-setscopeoptions.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.

SetScopeOptions


The SetScopeOptions script invokes the SetScopeOptions operation to set some options on a scope. It must be executed as follows:

./setscopeoptions.sh <VREManager host> <VREManager port> <configuration file>

This is an example of configuration file that can be provided:

callerScope=/gcube/devsec/BigBang

# scope options
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=BigBangVRE
description=secondVRE
startTime=2008-11-11T16:58:12+01:00
endTime=2008-11-21T19:00:00+01:00

AddResource


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

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

Clearly, the VREManager host and port are the information needed to contact the VREManager 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 the creation of two resources of type Service:

#global properties
numOfServicesToAdd=2
targetScope=/gcube/devsec
callerScope=/gcube/devsec

# resource list
service.1.name=IS-Notifier
service.1.class=InformationSystem
service.1.version=1.00.00
#GHNID on which the resource will be created
service.1.GHN=a938b7d0-88ce-11dd-a38a-f9b09f00a04e

service.2.name=AuthorizationService
service.2.class=DVOS
service.2.version=1.00.00
#GHNID on which the resource will be created
service.2.GHN=a938b7d0-88ce-11dd-a38a-f9b09f00a04e

This request will trigger the creation of a running instance for each of the two given services on the gHN identified by the service.X.GHN parameter.The VREManager is contacted with a call in the scope reported as value of the callerScope parameter and the instances will be created within the targetScope.

If we want to let the VREManager to decide on which gHNs to deploy, we must pass the GHNSet property with a comma-separated list of GHN IDs and remove the service.X.GHN properties:

#GHNID on which the service will be deployed
GHNSet=ad9e4820-b28c-11dd-9f37-e238d9877c06,a938b7d0-88ce-11dd-a38a-f9b09f00a04e

The operation always returns the Resource Report ID that can be used to invoke the GetReport operation.

GetReport


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

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

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