This commit is contained in:
Manuele Simi 2010-03-14 00:58:27 +00:00
parent 48cc9ca0aa
commit feeac7390b
10 changed files with 24 additions and 24 deletions

BIN
design/ResourceManager.vpp Normal file

Binary file not shown.

View File

@ -14,7 +14,6 @@ import org.gcube.common.core.resources.GCUBEResource;
import org.gcube.common.core.resources.GCUBEService;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.vremanagement.resourcemanager.impl.contexts.ServiceContext;
import org.gcube.vremanagement.resourcemanager.impl.scopemanagement.ScopedResourceManagerOperator.ACTION;
import org.gcube.common.core.informationsystem.client.AtomicCondition;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.ISTemplateQuery;
@ -35,13 +34,13 @@ import org.gcube.common.core.informationsystem.publisher.ISPublisher;
* @author Manuele Simi (ISTI-CNR)
*
*/
public class ScopedGenericResource extends ScopedResource {
public final class ScopedAnyResource extends ScopedResource {
GCUBEResource profile = null;
@SuppressWarnings("unchecked")
Class profileClass = null;
public ScopedGenericResource(String id, String type, GCUBEScope scope) {
public ScopedAnyResource(String id, String type, GCUBEScope scope) {
super(id, type, scope);
}
@ -80,9 +79,9 @@ public class ScopedGenericResource extends ScopedResource {
@Override
protected void addToScope() throws Exception {
this.status = STATUS.ADDREQUESTED;
if (profile == null)
this.find();
logger.debug("Adding scope to resource's profile");
profile.addScope(this.getScope());
//republish the resource
ISPublisher publisher = GHNContext.getImplementation(ISPublisher.class);
@ -96,10 +95,10 @@ public class ScopedGenericResource extends ScopedResource {
}
@Override
protected void removeFromScope() throws Exception {
this.status = STATUS.REMOVEREQUESTED;
protected void removeFromScope() throws Exception {
if (profile == null)
this.find();
logger.debug("Removing scope from resource's profile");
profile.removeScope(this.getScope());
//republish the resource
ISPublisher publisher = GHNContext.getImplementation(ISPublisher.class);
@ -112,6 +111,5 @@ public class ScopedGenericResource extends ScopedResource {
}
}
}

View File

@ -14,7 +14,7 @@ import org.gcube.vremanagement.resourcemanager.impl.deployment.resources.Deploye
* @author Manuele Simi (ISTI-CNR)
*
*/
public class ScopedDeployedService extends ScopedResource {
public final class ScopedDeployedService extends ScopedResource {
public static final String TYPE = GCUBEService.TYPE;

View File

@ -20,7 +20,7 @@ import org.gcube.vremanagement.resourcemanager.impl.contexts.ServiceContext;
* @author Manuele Simi (ISTI-CNR)
*
*/
public class ScopedGHN extends ScopedResource {
public final class ScopedGHN extends ScopedResource {
public static final String TYPE = GCUBEHostingNode.TYPE;

View File

@ -19,7 +19,7 @@ public class ScopedResourceFactory {
else if (type.compareToIgnoreCase(GCUBEService.TYPE) == 0)
sresource = new ScopedDeployedService(id, scope);
else
sresource = new ScopedGenericResource(id, type, scope);
sresource = new ScopedAnyResource(id, type, scope);
return sresource;
}

View File

@ -23,7 +23,7 @@ import org.gcube.vremanagement.resourcemanager.impl.contexts.ServiceContext;
* @author Manuele Simi (ISTI-CNR)
*
*/
public class ScopedRunningInstance extends ScopedResource {
public final class ScopedRunningInstance extends ScopedResource {
public static final String TYPE = GCUBERunningInstance.TYPE;

View File

@ -11,10 +11,10 @@ import org.gcube.vremanagement.resourcemanager.impl.operators.OperatorConfig;
import org.gcube.vremanagement.resourcemanager.impl.operators.Operator;
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedResource;
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedResourceFactory;
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedResource.STATUS;
/**
* Add and remove list of GCUBEResources to/from a given scope
* Add and remove list of {@link ScopedResource}s to/from a given scope
*
* @author Manuele Simi (ISTI-CNR)
*

View File

@ -20,7 +20,7 @@ import org.globus.wsrf.NoSuchResourceException;
* @author Manuele Simi (ISTI-CNR)
*
*/
public class InstanceState extends GCUBEWSResource {
public final class InstanceState extends GCUBEWSResource {
protected static final String ManagedScopeRP="ManagedScope";
@ -47,7 +47,7 @@ public class InstanceState extends GCUBEWSResource {
resourceList = new ResourceList(scope, scope.getName());
logger.info("Loading the instance state from the IS...");
if (this.getPublishedScopeResource().loaded()) {
logger.info("List of scoped resources harvested from the IS");
logger.info("Instance state harvested from the IS");
//synch resourceList w/ IS list
this.getPublishedScopeResource().to(resourceList);
} else

View File

@ -16,7 +16,7 @@ import java.util.Set;
import org.gcube.vremanagement.resourcemanager.impl.contexts.ServiceContext;
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedGHN;
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedGenericResource;
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedAnyResource;
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedResource;
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedRunningInstance;
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedResource.STATUS;
@ -590,7 +590,7 @@ public class PublishedScopeResource {
} else if (item.type.compareToIgnoreCase(ScopedRunningInstance.TYPE) == 0) {
resource = new ScopedRunningInstance(item.id, scope, item.hostedOn);
} else {
resource = new ScopedGenericResource(item.id, item.type, scope);
resource = new ScopedAnyResource(item.id, item.type, scope);
}
temp.add(resource);
}

View File

@ -10,8 +10,6 @@ import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedResource;
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedResource.STATUS;
import org.gcube.vremanagement.resourcemanager.impl.resources.types.MultiKeysMap;
import org.gcube.vremanagement.resourcemanager.impl.scopemanagement.ScopedResourceManagerOperator;
import com.thoughtworks.xstream.annotations.XStreamAlias;
/**
@ -126,8 +124,10 @@ public class ResourceList extends Observable {
* @param type the type of resources to remove
*/
public synchronized void removeAllResourcesByType(String type) {
for (ScopedResource resource : resources.getValuesBySecondaryKey(type))
for (ScopedResource resource : resources.getValuesBySecondaryKey(type)) {
resource.setStatus(STATUS.REMOVEREQUESTED);
resources.put(resource.getId(), resource.getType(), resource);//TODO: is needed?
}
this.setLastOperationPerformed(OPERATION.TOBEMANAGED);
this.notifyObservers();
resources.removeValuesBySecondaryKey(type);
@ -136,12 +136,14 @@ public class ResourceList extends Observable {
/**
* Removes the resources from the scope
*
* @param id the resources to remove
* @param oldresources the resources to remove
*
*/
public synchronized void removeResources(Set<ScopedResource> oldresources) {
for (ScopedResource resource : oldresources)
for (ScopedResource resource : oldresources) {
resource.setStatus(STATUS.REMOVEREQUESTED);
resources.put(resource.getId(), resource.getType(), resource);//TODO: is needed?
}
this.setLastOperationPerformed(OPERATION.TOBEMANAGED);
this.notifyObservers(); //let the obs do their work before to remove the resources
for (ScopedResource resource : oldresources) {
@ -171,13 +173,13 @@ public class ResourceList extends Observable {
}
public void notifyObservers(Object whatschanged) {
// Otherwise it won't propagate changes:
// Otherwise it won't propagate changes
setChanged();
super.notifyObservers(whatschanged);
}
public void notifyObservers() {
// Otherwise it won't propagate changes:
// Otherwise it won't propagate changes
setChanged();
super.notifyObservers();
}