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> <groupId>org.gcube.resourcemanagement</groupId>
<artifactId>resource-manager</artifactId> <artifactId>resource-manager</artifactId>
<version>2.0.3-SNAPSHOT</version> <version>2.0.4-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>Resource Manager Reactor</name> <name>Resource Manager Reactor</name>

View File

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

View File

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

View File

@ -97,7 +97,7 @@ public abstract class ScopedResource {
this.success = true; this.success = true;
break; break;
} catch (Exception e) { } 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) { if (i++ <= max_attempts) {
logger.warn("try again in 5 secs"); logger.warn("try again in 5 secs");
try {Thread.sleep(5000);} catch (InterruptedException e1) {} try {Thread.sleep(5000);} catch (InterruptedException e1) {}

View File

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

View File

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