force remove implemented, queries for the sweeper updated
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/admin/rmp-common-library@82027 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
da7a38a6b4
commit
9bc49c8fc6
21
pom.xml
21
pom.xml
|
@ -34,12 +34,22 @@
|
|||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
</properties>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>maven-portal-bom</artifactId>
|
||||
<version>LATEST</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
<!-- Google Web Toolkit (GWT) -->
|
||||
<dependency>
|
||||
<groupId>com.google.gwt</groupId>
|
||||
<artifactId>gwt-user</artifactId>
|
||||
<version>${gwtVersion}</version>
|
||||
<!-- "provided" so that we don't deploy -->
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
@ -53,7 +63,11 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.resources.discovery</groupId>
|
||||
<artifactId>ic-client</artifactId>
|
||||
<version>1.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-scope-maps</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.resourcemanagement</groupId>
|
||||
|
@ -73,18 +87,15 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.resourcemanagement</groupId>
|
||||
<artifactId>ghnmanager-stubs</artifactId>
|
||||
<version>[1.5.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
<!-- END FWS -->
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.16</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.thoughtworks.xstream</groupId>
|
||||
<artifactId>xstream</artifactId>
|
||||
<version>1.3.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -55,11 +55,11 @@ public enum ResourceTypeDecorator {
|
|||
/****************************************
|
||||
* Models for SWEEPER
|
||||
***************************************/
|
||||
Sweeper_GHN("gCube Hosting Node", "ghn-icon",""),
|
||||
Sweeper_RI("Running Instance", "runninginstance-icon",""),
|
||||
Sweeper_RI_Orphan("Orphan Running Instance", "orphan-runninginstance-icon",""),
|
||||
Sweeper_GHN_Expired("Expired gHN", "expired-ghn-icon",""),
|
||||
Sweeper_GHN_Dead("Dead gHN", "dead-ghn-icon","");
|
||||
Sweeper_GHN("gCube Hosting Node", "ghn-icon","Hosting Node"),
|
||||
Sweeper_RI("Running Instance", "runninginstance-icon", "GCore Endpoint"),
|
||||
Sweeper_RI_Orphan("Orphan Running Instance", "orphan-runninginstance-icon", "Orphan GCore Endpoint"),
|
||||
Sweeper_GHN_Expired("Expired gHN", "expired-ghn-icon", "Expired Nodes"),
|
||||
Sweeper_GHN_Dead("Dead gHN", "dead-ghn-icon", "Unreachable Nodes");
|
||||
|
||||
|
||||
private String fwsName = null;
|
||||
|
|
|
@ -64,8 +64,13 @@ public enum QueryLocation {
|
|||
|
||||
// Queries for sweeper
|
||||
SWEEPER_EXPIRED_GHN("sweeper/expiredGhns.xq"),
|
||||
RETURN_SWEEPER_EXPIRED_GHN("sweeper/RETURN_expiredGhns.xq"),
|
||||
|
||||
SWEEPER_DEAD_GHN("sweeper/deadGhns.xq"),
|
||||
RETURN_SWEEPER_DEAD_GHN("sweeper/RETURN_deadGhns.xq"),
|
||||
|
||||
SWEEPER_ORPHAN_RI("sweeper/orphanRI.xq"),
|
||||
RETURN_SWEEPER_ORPHAN_RI("sweeper/RETURN_orphanRI.xq"),
|
||||
|
||||
// Used to build the gwt model representation inside dialogs.
|
||||
// see getResourceModels inside ISClientRequester.
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<Resource>
|
||||
{$GHNs/ID}
|
||||
{$GHNs/Profile/GHNDescription/Name}
|
||||
{$GHNs/Profile/GHNDescription/Status}
|
||||
{$GHNs/Profile/GHNDescription/Type}
|
||||
{$GHNs/Profile/Site/Location}
|
||||
{$GHNs/Profile/Site/Domain}
|
||||
<IPAddress>{$GHNs/Profile/GHNDescription/NetworkAdapter/@IPAddress/string()}</IPAddress>
|
||||
<Scopes>{$scopes}</Scopes>
|
||||
<AllocatedRI>{count($RIinstalled)}</AllocatedRI>
|
||||
{$GHNs/Profile/GHNDescription/LastUpdate}
|
||||
<UpdateMinutesElapsed>{$totalminutes}</UpdateMinutesElapsed>
|
||||
<Actions>APPLY_GHN_DELETE</Actions>
|
||||
</Resource>
|
|
@ -0,0 +1,13 @@
|
|||
<Resource>
|
||||
{$GHNs/ID}
|
||||
{$GHNs/Profile/GHNDescription/Name}
|
||||
{$GHNs/Profile/GHNDescription/Status}
|
||||
{$GHNs/Profile/GHNDescription/Type}
|
||||
{$GHNs/Profile/Site/Location}
|
||||
{$GHNs/Profile/Site/Domain}
|
||||
<IPAddress>{$GHNs/Profile/GHNDescription/NetworkAdapter/@IPAddress/string()}</IPAddress>
|
||||
<Scopes>{$scopes}</Scopes>
|
||||
<AllocatedRI>{count($RIinstalled)}</AllocatedRI>
|
||||
{$GHNs/Profile/GHNDescription/LastUpdate}
|
||||
<Actions>APPLY_GHN_MOVE_TO_UNREACHABLE</Actions>
|
||||
</Resource>
|
|
@ -0,0 +1,9 @@
|
|||
<Resource>
|
||||
<ID>{$ri//Resource/ID/string()}</ID>
|
||||
<ServiceStatus>{$ri/Profile/DeploymentData/Status/string()}</ServiceStatus>
|
||||
<ActivationTime>{$ri/Profile/DeploymentData/ActivationTime/@value/string()}</ActivationTime>
|
||||
<ghnid>{$ri/Profile/GHN/@UniqueID/string()}</ghnid>
|
||||
<ServiceClass>{$ri/Profile/ServiceClass/string()}</ServiceClass>
|
||||
<ServiceName>{$ri/Profile/ServiceName/string()}</ServiceName>
|
||||
<Actions>APPLY_RI_DELETE</Actions>
|
||||
</Resource>
|
|
@ -10,20 +10,4 @@ let $RIinstalled := $RIs[Profile/GHN/string(@UniqueID)=$GHNs/ID]
|
|||
let $scopes := string-join( $GHNs/Scopes//Scope/text(), ';')
|
||||
where ($GHNs/Profile/GHNDescription/Status/string() eq 'down' or $GHNs/Profile/GHNDescription/Status/string() eq 'unreachable')
|
||||
return
|
||||
<Resource>
|
||||
{$GHNs/ID}
|
||||
{$GHNs/Profile/GHNDescription/Name}
|
||||
{$GHNs/Profile/GHNDescription/Status}
|
||||
{$GHNs/Profile/GHNDescription/Type}
|
||||
{$GHNs/Profile/Site/Location}
|
||||
{$GHNs/Profile/Site/Domain}
|
||||
<IPAddress>{$GHNs/Profile/GHNDescription/NetworkAdapter/@IPAddress/string()}</IPAddress>
|
||||
<!--
|
||||
Other info
|
||||
-->
|
||||
<Scopes>{$scopes}</Scopes>
|
||||
<AllocatedRI>{count($RIinstalled)}</AllocatedRI>
|
||||
{$GHNs/Profile/GHNDescription/LastUpdate}
|
||||
<UpdateMinutesElapsed>{$totalminutes}</UpdateMinutesElapsed>
|
||||
<Actions><ACTION ISdefault ='APPLY_GHN_DELETE'/></Actions>
|
||||
</Resource>
|
||||
<RESOURCE/>
|
|
@ -9,19 +9,4 @@ let $RIinstalled := $RIs[Profile/GHN/string(@UniqueID)=$GHNs/ID]
|
|||
let $scopes := string-join( $GHNs/Scopes//Scope/text(), ';')
|
||||
where $GHNs/Profile/GHNDescription/Status/string() != 'down' and $GHNs/Profile/GHNDescription/Status/string() != 'unreachable'
|
||||
return
|
||||
<Resource>
|
||||
{$GHNs/ID}
|
||||
{$GHNs/Profile/GHNDescription/Name}
|
||||
{$GHNs/Profile/GHNDescription/Status}
|
||||
{$GHNs/Profile/GHNDescription/Type}
|
||||
{$GHNs/Profile/Site/Location}
|
||||
{$GHNs/Profile/Site/Domain}
|
||||
<IPAddress>{$GHNs/Profile/GHNDescription/NetworkAdapter/@IPAddress/string()}</IPAddress>
|
||||
<!--
|
||||
Other info
|
||||
-->
|
||||
<Scopes>{$scopes}</Scopes>
|
||||
<AllocatedRI>{count($RIinstalled)}</AllocatedRI>
|
||||
{$GHNs/Profile/GHNDescription/LastUpdate}
|
||||
<Actions><ACTION ISdefault ='APPLY_GHN_MOVE_TO_UNREACHABLE'/></Actions>
|
||||
</Resource>
|
||||
<RESOURCE/>
|
|
@ -4,16 +4,4 @@ for $ri in $ris
|
|||
let $counter := index-of(($ghns//ID/string()), $ri/Profile/GHN/@UniqueID/string())
|
||||
where empty($counter)
|
||||
return
|
||||
<Resource>
|
||||
<ID>{$ri//Resource/ID/string()}</ID>
|
||||
<ServiceStatus>{$ri/Profile/DeploymentData/Status/string()}</ServiceStatus>
|
||||
<ActivationTime>{$ri/Profile/DeploymentData/ActivationTime/@value/string()}</ActivationTime>
|
||||
<ghnid>{$ri/Profile/GHN/@UniqueID/string()}</ghnid>
|
||||
<ServiceClass>{$ri/Profile/ServiceClass/string()}</ServiceClass>
|
||||
<ServiceName>{$ri/Profile/ServiceName/string()}</ServiceName>
|
||||
<!-- <tmp>{$ghns//ID}</tmp> -->
|
||||
<!--
|
||||
The actions must be declared inside the SweeperAction enum declaration.
|
||||
-->
|
||||
<Actions><ACTION ISdefault ='APPLY_RI_DELETE'/></Actions>
|
||||
</Resource>
|
||||
<RESOURCE/>
|
|
@ -26,6 +26,7 @@ import org.gcube.common.resources.gcore.Resource;
|
|||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
import org.gcube.common.scope.impl.ScopeBean.Type;
|
||||
import org.gcube.informationsystem.publisher.AdvancedPublisher;
|
||||
import org.gcube.informationsystem.publisher.RegistryPublisher;
|
||||
import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
|
||||
import org.gcube.resourcemanagement.support.server.exceptions.AbstractResourceException;
|
||||
|
@ -175,7 +176,7 @@ public abstract class AbstractResourceManager {
|
|||
* @throws ResourceParameterException if the parameters are invalid
|
||||
*/
|
||||
public final RMBinderLibrary getResourceManager(String scope) throws AbstractResourceException {
|
||||
|
||||
|
||||
ScopeBean bscope = new ScopeBean(scope);
|
||||
if (bscope.is(Type.VRE)) {
|
||||
scope = bscope.enclosingScope().toString();
|
||||
|
@ -202,7 +203,7 @@ public abstract class AbstractResourceManager {
|
|||
scope = bscope.enclosingScope().toString();
|
||||
}
|
||||
ScopeProvider.instance.set(scope);
|
||||
|
||||
|
||||
ServerConsole.info(LOG_PREFIX, "Getting Resource Manager in scope [" + scope.toString() + "]");
|
||||
RMReportingLibrary rml = Proxies.reportingService().build();
|
||||
if (rml == null) { // no managers found
|
||||
|
@ -232,7 +233,7 @@ public abstract class AbstractResourceManager {
|
|||
targetScope.toString() + "]");
|
||||
String curr = ScopeProvider.instance.get();
|
||||
ScopeProvider.instance.set(targetScope.toString());
|
||||
|
||||
|
||||
AddResourcesParameters addParam = new AddResourcesParameters();
|
||||
ResourceItem toAdd = new ResourceItem();
|
||||
toAdd.setId(this.getID());
|
||||
|
@ -261,7 +262,7 @@ public abstract class AbstractResourceManager {
|
|||
targetScope.toString() + "]... reportID: " + reportID);
|
||||
|
||||
RMReportingLibrary pt = this.getReportResourceManager(scope.toString());
|
||||
|
||||
|
||||
String toReturn = pt.getReport(reportID);
|
||||
ScopeProvider.instance.set(curr);
|
||||
return toReturn;
|
||||
|
@ -286,7 +287,7 @@ public abstract class AbstractResourceManager {
|
|||
checker.validate(sourceScope != null, new ResourceParameterException("Invalid parameter sourceScope. null not allowed."));
|
||||
checker.validate(targetScope != null, new ResourceParameterException("Invalid parameter targetScope. null not allowed."));
|
||||
checker.validate(this.getID() != null, new ResourceOperationException("Invalid resource ID. null not allowed."));
|
||||
|
||||
|
||||
String curr = ScopeProvider.instance.get();
|
||||
ScopeProvider.instance.set(sourceScope.toString());
|
||||
ReportBuilder report = new ReportBuilder();
|
||||
|
@ -319,7 +320,7 @@ public abstract class AbstractResourceManager {
|
|||
targetScope.toString() + " the remote report ID is: " +
|
||||
this.bindToScope(targetScope.toString()), true));
|
||||
|
||||
|
||||
|
||||
String toReturn = report.getXML();
|
||||
ScopeProvider.instance.set(curr);
|
||||
return toReturn;
|
||||
|
@ -407,9 +408,9 @@ public abstract class AbstractResourceManager {
|
|||
protected final String getXMLDescription(final ScopeBean scope) throws AbstractResourceException {
|
||||
Assertion<AbstractResourceException> checker = new Assertion<AbstractResourceException>();
|
||||
checker.validate(this.getID() != null, new ResourceAccessException("Cannot execute on resources with no ID."));
|
||||
|
||||
|
||||
ScopeProvider.instance.set(scope.toString());
|
||||
|
||||
|
||||
// Phase 1. retrieve the resource to copy
|
||||
Query query = new QueryBox("for $resource in collection('/db/Profiles/" + this.getType().name() + "')//Resource " +
|
||||
"where ( $resource/ID/string() eq '" +
|
||||
|
@ -423,7 +424,7 @@ public abstract class AbstractResourceManager {
|
|||
if (results == null || results.isEmpty())
|
||||
throw new ResourceAccessException("Cannot retrieve the IS profile for resource: " + this.getID() +
|
||||
" in scope: " + scope.toString());
|
||||
|
||||
|
||||
return results.get(0).toString();
|
||||
}
|
||||
|
||||
|
@ -475,10 +476,10 @@ public abstract class AbstractResourceManager {
|
|||
Assertion<AbstractResourceException> checker = new Assertion<AbstractResourceException>();
|
||||
checker.validate(scope != null, new ResourceParameterException("Invalid parameter scope. null not allowed."));
|
||||
checker.validate(this.getID() != null, new ResourceOperationException("Invalid ID. null not allowed."));
|
||||
|
||||
|
||||
ScopeProvider.instance.set(scope.toString());
|
||||
String retval = this.basicRemoveFromScope(scope);
|
||||
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -503,14 +504,20 @@ public abstract class AbstractResourceManager {
|
|||
* @param scope where the resource is bound
|
||||
* @throws AbstractResourceException
|
||||
*/
|
||||
public final void forceDelete(final ScopeBean scope) throws AbstractResourceException {
|
||||
ServerConsole.trace(LOG_PREFIX, "[DELETE] [DELETE-BRANCH] deleting resource since no more scopes remained");
|
||||
Resource resStub = this.getResource(scope);
|
||||
try {
|
||||
this.getRegistryPublisher().remove(resStub);
|
||||
} catch (Exception e) {
|
||||
ServerConsole.error(LOG_PREFIX, e);
|
||||
}
|
||||
public final void forceDelete(ScopeBean scope) throws AbstractResourceException {
|
||||
ServerConsole.trace(LOG_PREFIX, "[FORCE DELETE] [DELETE-BRANCH] deleting resource from scope " + scope);
|
||||
String currScope = ScopeProvider.instance.get();
|
||||
|
||||
Resource toDelete = this.getResource(scope);
|
||||
|
||||
while (scope.enclosingScope() != null)
|
||||
scope = scope.enclosingScope();
|
||||
|
||||
ScopeProvider.instance.set(scope.toString());
|
||||
AdvancedPublisher advancedPublisher = new AdvancedPublisher(this.getRegistryPublisher());
|
||||
advancedPublisher.forceRemove(toDelete);
|
||||
ServerConsole.trace(LOG_PREFIX, "[FORCE DELETE] [DELETE-BRANCH] deleted resource from scope " + scope);
|
||||
ScopeProvider.instance.set(currScope);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -528,8 +535,8 @@ public abstract class AbstractResourceManager {
|
|||
checker.validate(this.getID() != null, new ResourceOperationException("Invalid ID. null not allowed."));
|
||||
|
||||
System.out.println("DELETING TYPE: "+ this.getType());
|
||||
ScopeProvider.instance.set(scope.toString());
|
||||
|
||||
String currScope = ScopeProvider.instance.get();
|
||||
ScopeProvider.instance.set(scope.toString());
|
||||
Resource resStub = this.getResource(scope);
|
||||
|
||||
List<ScopeBean> boundedScopes = this.validateScopes(resStub.scopes().toArray(new String[0]));
|
||||
|
@ -545,8 +552,9 @@ public abstract class AbstractResourceManager {
|
|||
try {
|
||||
this.getRegistryPublisher().remove(resStub);
|
||||
} catch (Exception e) {
|
||||
|
||||
ScopeProvider.instance.set(currScope);
|
||||
}
|
||||
ScopeProvider.instance.set(currScope);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ public class GHNManager extends AbstractResourceManager {
|
|||
}
|
||||
return this.addToExistingScope(sourceScope, targetScope);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* <b>Required information:</b>
|
||||
|
|
|
@ -129,7 +129,7 @@ implements PersistenceHandler<T> {
|
|||
while ((currLine = reader.readLine()) != null) {
|
||||
xml.append(currLine);
|
||||
}
|
||||
|
||||
reader.close();
|
||||
return (T) this.getSerializer().fromXML(xml.toString());
|
||||
} catch (Exception e) {
|
||||
ServerConsole.error(LOG_PREFIX, e);
|
||||
|
|
Loading…
Reference in New Issue