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:
Massimiliano Assante 2013-09-26 10:13:17 +00:00
parent da7a38a6b4
commit 9bc49c8fc6
12 changed files with 97 additions and 80 deletions

21
pom.xml
View File

@ -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>

View File

@ -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;

View File

@ -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.

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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/>

View File

@ -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/>

View File

@ -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/>

View File

@ -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;
@ -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());
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);
}
}

View File

@ -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);