added log on resource scope

pom: changed gcf range
pom: update to version 2.0.4

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vre-management/ResourceManager@101896 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Roberto Cirillo 2014-12-04 16:32:56 +00:00
parent 1ef80dae0b
commit 24d583976b
6 changed files with 40 additions and 15 deletions

View File

@ -11,7 +11,7 @@
<groupId>org.gcube.resourcemanagement</groupId>
<artifactId>resource-manager</artifactId>
<version>2.0.3-SNAPSHOT</version>
<version>2.0.4-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Resource Manager Reactor</name>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>org.gcube.resourcemanagement</groupId>
<artifactId>resource-manager</artifactId>
<version>2.0.3-SNAPSHOT</version>
<version>2.0.4-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

View File

@ -58,7 +58,7 @@ public final class ScopedAnyResource extends ScopedResource {
@Override
@SuppressWarnings({ "unchecked", "rawtypes"})
protected void find() throws Exception {
try {
ISClient client = GHNContext.getImplementation(ISClient.class);
Class query = null;
if (this.type.compareToIgnoreCase(GCUBECollection.TYPE) == 0) {query = GCUBECollectionQuery.class; profileClass = GCUBECollection.class;}
@ -70,19 +70,41 @@ public final class ScopedAnyResource extends ScopedResource {
else if (this.type.compareToIgnoreCase(GCUBEService.TYPE) == 0) {query = GCUBEServiceQuery.class; profileClass = GCUBEService.class;}
else if (this.type.compareToIgnoreCase(GCUBERuntimeResource.TYPE) == 0) {query = GCUBERuntimeResourceQuery.class; profileClass = GCUBERuntimeResource.class;}
else throw new Exception("Unknown resource type: " + this.type);
ISTemplateQuery realquery = (ISTemplateQuery) client.getQuery(query);
realquery.addAtomicConditions(new AtomicCondition("/ID",this.id));
List <GCUBEResource> profiles = client.execute(realquery, GCUBEScope.getScope(this.scope));
if ((profiles != null) && (profiles.size() > 0))
this.profile = profiles.get(0);
else
// obviously, in the case of adding, the resource is not in the current scope, therefore we look upstairs (the enclosing scope)
this.profile = (GCUBEResource) client.execute(realquery, GCUBEScope.getScope(this.scope).getEnclosingScope()).get(0);
List <GCUBEResource> profiles=null;
ISTemplateQuery realquery =null;
try {
realquery = (ISTemplateQuery) client.getQuery(query);
logger.info("execution query "+query+" on scope "+scope+" with id: "+this.id);
realquery.addAtomicConditions(new AtomicCondition("/ID",this.id));
profiles = client.execute(realquery, GCUBEScope.getScope(this.scope));
if ((profiles != null) && (profiles.size() > 0)){
logger.info("profile found ");
this.profile = profiles.get(0);
}else{
GCUBEScope enclosingScope=GCUBEScope.getScope(this.scope).getEnclosingScope();
logger.info("profile not found. Try on enclosing scope: "+enclosingScope);
// obviously, in the case of adding, the resource is not in the current scope, therefore we look upstairs (the enclosing scope)
this.profile = (GCUBEResource) client.execute(realquery, enclosingScope).get(0);
}
} catch (Throwable e) {
getLogger().error("bad query. Caused by: "+e.getCause());
throw new Exception("unable to find the target resource (ID=" + id + "). Possible cause: " + e.getMessage(), e);
}
// try{
// if ((profiles != null) && (profiles.size() > 0)){
// logger.info("profile found ");
// this.profile = profiles.get(0);
// }else{
// GCUBEScope enclosingScope=GCUBEScope.getScope(this.scope).getEnclosingScope();
// logger.info("profile not found. Try on enclosing scope: "+enclosingScope);
// // obviously, in the case of adding, the resource is not in the current scope, therefore we look upstairs (the enclosing scope)
// this.profile = (GCUBEResource) client.execute(realquery, enclosingScope).get(0);
// }
// }catch(Throwable e){
// getLogger().error("bad query. Caused by: "+e.getCause());
// throw new Exception("unable to find the target resource (ID=" + id + "). Possible cause: " + e.getMessage(), e);
//
// }
}
@ -92,12 +114,15 @@ public final class ScopedAnyResource extends ScopedResource {
getLogger().debug("Adding scope to resource profile");
try {
profile.addScope(this.getScope());
getLogger().debug("republish the resource "+profile.getID()+" with scope added "+this.getScope());
//republish the resource
ISPublisher publisher = GHNContext.getImplementation(ISPublisher.class);
publisher.updateGCUBEResource(this.profile, ServiceContext.getContext().getScope(), ServiceContext.getContext());
getLogger().debug("ServiceContext scope: "+ServiceContext.getContext().getScope());
//republish also in the infrastructure scope, if needed
if (ServiceContext.getContext().getScope().getType() == GCUBEScope.Type.VO) {
if (this.profile.getScopes().values().contains(ServiceContext.getContext().getScope().getEnclosingScope())) {
getLogger().debug(" published also on: "+ServiceContext.getContext().getScope().getEnclosingScope());
publisher.updateGCUBEResource(this.profile, ServiceContext.getContext().getScope().getEnclosingScope(), ServiceContext.getContext());
}
}

View File

@ -97,7 +97,7 @@ public abstract class ScopedResource {
this.success = true;
break;
} catch (Exception e) {
logger.warn("Can't find the resource "+ this.getId() + " on the IS");
logger.warn("Can't find the resource "+ this.getId() + " on the IS in scope: "+scope);
if (i++ <= max_attempts) {
logger.warn("try again in 5 secs");
try {Thread.sleep(5000);} catch (InterruptedException e1) {}

View File

@ -7,7 +7,7 @@
<parent>
<groupId>org.gcube.resourcemanagement</groupId>
<artifactId>resource-manager</artifactId>
<version>2.0.3-SNAPSHOT</version>
<version>2.0.4-SNAPSHOT</version>
</parent>
<artifactId>resource-manager-stubs</artifactId>
<name>Resource Manager Stubs</name>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>org.gcube.resourcemanagement</groupId>
<artifactId>resource-manager</artifactId>
<version>2.0.3-SNAPSHOT</version>
<version>2.0.4-SNAPSHOT</version>
</parent>
<artifactId>resource-manager-test-suite</artifactId>