Code cleanup from unused portType and state. Improved purging and package reorganization.
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@36413 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
0a42a72939
commit
f328250842
|
@ -11,58 +11,6 @@
|
|||
override="false" />
|
||||
-->
|
||||
|
||||
</service>
|
||||
|
||||
<service name="gcube/informationsystem/registry/Registry">
|
||||
|
||||
<environment name="name" value="Registry" type="java.lang.String"
|
||||
override="false" />
|
||||
|
||||
<environment name="RPDName" value="ProfileResourceProperties"
|
||||
type="java.lang.String" override="false" />
|
||||
|
||||
|
||||
<resource name="publicationProfile"
|
||||
type="org.gcube.common.core.state.GCUBEPublicationProfile">
|
||||
<resourceParams>
|
||||
<parameter>
|
||||
<name>factory</name>
|
||||
<value>org.globus.wsrf.jndi.BeanFactory</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>mode</name>
|
||||
<value>push</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>fileName</name>
|
||||
<value>registration.xml</value>
|
||||
</parameter>
|
||||
</resourceParams>
|
||||
</resource>
|
||||
|
||||
<resource name="home"
|
||||
type="org.gcube.informationsystem.registry.impl.state.ProfileResourceHome">
|
||||
|
||||
<resourceParams>
|
||||
<parameter>
|
||||
<name>factory</name>
|
||||
<value>org.globus.wsrf.jndi.BeanFactory</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>resourceClass</name>
|
||||
<value>org.gcube.informationsystem.registry.impl.state.ProfileResource
|
||||
</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>sweeperDelay</name>
|
||||
<value>10000</value>
|
||||
</parameter>
|
||||
</resourceParams>
|
||||
|
||||
</resource>
|
||||
|
||||
|
||||
|
||||
</service>
|
||||
|
||||
<service name="gcube/informationsystem/registry/ResourceRegistration">
|
||||
|
|
|
@ -5,18 +5,6 @@
|
|||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:aggr="http://mds.globus.org/aggregator/types">
|
||||
|
||||
<service name="gcube/informationsystem/registry/Registry" provider="Handler" use="literal" style="document">
|
||||
<parameter name="className" value="org.gcube.informationsystem.registry.impl.porttypes.Registry"/>
|
||||
<wsdlFile>share/schema/org.gcube.informationsystem.registry/Registry_service.wsdl</wsdlFile>
|
||||
<parameter name="allowedMethods" value="*"/>
|
||||
<parameter name="handlerClass" value="org.globus.axis.providers.RPCProvider"/>
|
||||
<parameter name="scope" value="Application"/>
|
||||
<parameter name="providers" value="GCUBEProvider SubscribeProvider DestroyProvider GetCurrentMessageProvider "/>
|
||||
<parameter name="loadOnStartup" value="true"/>
|
||||
<!-- <parameter name="securityDescriptor" value="@config.dir@/security-descriptor-Service.xml"/> -->
|
||||
</service>
|
||||
|
||||
|
||||
<!-- Factory service -->
|
||||
<service name="gcube/informationsystem/registry/RegistryFactory" provider="Handler" use="literal" style="document">
|
||||
<parameter name="className" value="org.gcube.informationsystem.registry.impl.porttypes.RegistryFactory"/>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<Main>
|
||||
<Description>IS-Registry: validate, register and unregister GCUBE resources to/from the IS. It also publishes Topics for notifications about GCUBE resource events</Description>
|
||||
<Name>IS-Registry-service</Name>
|
||||
<Version>2.0.0</Version>
|
||||
<Version>2.1.0</Version>
|
||||
<Mandatory level="VO"/>
|
||||
<Shareable level="VO"/>
|
||||
<GHNRequirements>
|
||||
|
@ -32,7 +32,7 @@
|
|||
<Version>1.0.0</Version>
|
||||
</Service>
|
||||
<Package>IS-Registry-stubs</Package>
|
||||
<Version>2.0.0</Version>
|
||||
<Version>2.1.0</Version>
|
||||
<Scope level="GHN"/>
|
||||
<Optional>false</Optional>
|
||||
</Dependency>
|
||||
|
@ -48,16 +48,11 @@
|
|||
<Security/>
|
||||
<WSDL/>
|
||||
</PortType>
|
||||
<PortType>
|
||||
<Name>gcube/informationsystem/registry/Registry</Name>
|
||||
<Security/>
|
||||
<WSDL/>
|
||||
</PortType>
|
||||
</Main>
|
||||
<Software>
|
||||
<Description>IS-Registry: validate, register and unregister GCUBE resources to/from the IS. It also publishes Topics for notifications about GCUBE resource events</Description>
|
||||
<Name>IS-Registry-stubs</Name>
|
||||
<Version>2.0.0</Version>
|
||||
<Version>2.1.0</Version>
|
||||
<MultiVersion value="true"/>
|
||||
<Mandatory level="GHN"/>
|
||||
<Shareable level="VO"/>
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
package org.gcube.informationsystem.registry.impl.contexts;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.core.contexts.GCUBEServiceContext;
|
||||
import org.gcube.common.core.contexts.GHNContext;
|
||||
import static org.gcube.common.core.contexts.GHNContext.Mode;
|
||||
|
@ -16,10 +11,9 @@ import org.gcube.common.core.utils.events.GCUBEProducer;
|
|||
import org.gcube.common.core.utils.events.GCUBETopic;
|
||||
import org.gcube.common.core.utils.handlers.GCUBEScheduledHandler;
|
||||
import org.gcube.informationsystem.registry.impl.local.LocalProfileConsumerImpl;
|
||||
import org.gcube.informationsystem.registry.impl.purging.AvailablePurgers;
|
||||
import org.gcube.informationsystem.registry.impl.purging.GHNPurger;
|
||||
import org.gcube.informationsystem.registry.impl.purging.RIPurger;
|
||||
import org.gcube.informationsystem.registry.impl.resourcemanagement.EliminatePoolingThread;
|
||||
import org.gcube.informationsystem.registry.impl.postprocessing.purging.AvailablePurgers;
|
||||
import org.gcube.informationsystem.registry.impl.postprocessing.purging.GHNPurger;
|
||||
import org.gcube.informationsystem.registry.impl.postprocessing.purging.RIPurger;
|
||||
|
||||
|
||||
|
||||
|
@ -33,8 +27,6 @@ public class ServiceContext extends GCUBEServiceContext {
|
|||
|
||||
public static final String JNDI_NAME = "gcube/informationsystem/registry";
|
||||
|
||||
public static Map<String, EliminatePoolingThread> threadTable = Collections.synchronizedMap(new HashMap<String, EliminatePoolingThread>());
|
||||
|
||||
protected static final ServiceContext cache = new ServiceContext();
|
||||
|
||||
protected ISClient client = null;
|
||||
|
|
|
@ -10,10 +10,10 @@ import org.gcube.common.core.utils.logging.GCUBELog;
|
|||
import org.gcube.informationsystem.registry.impl.contexts.ServiceContext;
|
||||
import org.gcube.informationsystem.registry.impl.contexts.ServiceContext.RegistryTopic;
|
||||
import org.gcube.informationsystem.registry.impl.local.LocalNotifier;
|
||||
import org.gcube.informationsystem.registry.impl.purging.AvailablePurgers;
|
||||
import org.gcube.informationsystem.registry.impl.purging.Purger;
|
||||
import org.gcube.informationsystem.registry.impl.postprocessing.purging.AvailablePurgers;
|
||||
import org.gcube.informationsystem.registry.impl.postprocessing.purging.Purger;
|
||||
import org.gcube.informationsystem.registry.impl.state.Definitions.OperationType;
|
||||
import org.gcube.informationsystem.registry.impl.state.Definitions.ResourceType;
|
||||
import org.gcube.informationsystem.registry.impl.state.Definitions.ResourceMappings;
|
||||
|
||||
public class LocalResourceRegistration {
|
||||
|
||||
|
@ -27,7 +27,7 @@ public class LocalResourceRegistration {
|
|||
LocalNotifier.notifyEvent(resource, RegistryTopic.CREATE);
|
||||
StringWriter writer = new StringWriter();
|
||||
resource.store(writer);
|
||||
RegistryFactory.updateCounterInfo(resource.getID(), ResourceType.valueOf(
|
||||
RegistryFactory.updateCounterInfo(resource.getID(), ResourceMappings.valueOf(
|
||||
resource.getType()), OperationType.create,
|
||||
Calendar.getInstance(), writer.toString());
|
||||
}
|
||||
|
@ -42,18 +42,22 @@ public class LocalResourceRegistration {
|
|||
publisher.remove(id, type, ServiceContext.getContext().getScope(), ServiceContext.getContext());
|
||||
logger.debug("Resource " + id+ " successfully removed");
|
||||
// if there is a purger available, remove also the related RIs
|
||||
Purger<?> purger = AvailablePurgers.getPurger(ResourceType.valueOf(type).getResourceImplementation().getClass());
|
||||
if (purger != null)
|
||||
logger.trace("Looking for purger for "+ type);
|
||||
Purger<?> purger = AvailablePurgers.getPurger(type);
|
||||
if (purger != null) {
|
||||
try {
|
||||
logger.debug("Applying purger for " + type);
|
||||
purger.purge(id, ServiceContext.getContext().getScope());
|
||||
} catch (Exception e) {
|
||||
logger.error("Error while removing the profiles related to the resource", e);
|
||||
}
|
||||
} else
|
||||
logger.trace("No purger found");
|
||||
//let the notifiers know
|
||||
GCUBEResource resource = ResourceType.valueOf(type).getResourceImplementation();
|
||||
GCUBEResource resource = ResourceMappings.valueOf(type).getResourceImplementation();
|
||||
resource.setID(id);
|
||||
LocalNotifier.notifyEvent(resource, RegistryTopic.REMOVE);
|
||||
RegistryFactory.updateCounterInfo(id, ResourceType.valueOf(type),OperationType.destroy, Calendar.getInstance(), null);
|
||||
RegistryFactory.updateCounterInfo(id, ResourceMappings.valueOf(type),OperationType.destroy, Calendar.getInstance(), null);
|
||||
}
|
||||
|
||||
public void update(GCUBEResource resource) throws Exception {
|
||||
|
@ -63,7 +67,7 @@ public class LocalResourceRegistration {
|
|||
LocalNotifier.notifyEvent(resource, RegistryTopic.UPDATE);
|
||||
StringWriter writer = new StringWriter();
|
||||
resource.store(writer);
|
||||
RegistryFactory.updateCounterInfo(resource.getID(), ResourceType.valueOf(resource.getType()),
|
||||
RegistryFactory.updateCounterInfo(resource.getID(), ResourceMappings.valueOf(resource.getType()),
|
||||
OperationType.update, Calendar.getInstance(), writer.toString());
|
||||
|
||||
}
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
package org.gcube.informationsystem.registry.impl.porttypes;
|
||||
|
||||
import org.apache.axis.utils.XMLUtils;
|
||||
import org.gcube.common.core.contexts.GCUBEServiceContext;
|
||||
import org.gcube.common.core.faults.GCUBEFault;
|
||||
import org.gcube.common.core.porttypes.GCUBEPortType;
|
||||
import org.gcube.informationsystem.registry.impl.contexts.ProfileContext;
|
||||
import org.gcube.informationsystem.registry.impl.contexts.ServiceContext;
|
||||
import org.gcube.informationsystem.registry.impl.state.ProfileResource;
|
||||
import org.gcube.informationsystem.registry.stubs.GetProfileString;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of the <em>Registry</em> portType
|
||||
*
|
||||
* @author Manuele Simi (CNR)
|
||||
*
|
||||
*/
|
||||
public class Registry extends GCUBEPortType {
|
||||
|
||||
/**
|
||||
* Gets a string representation of the profile
|
||||
* @param voidType
|
||||
* @return a string representation of the profile
|
||||
* @throws GCUBEFault
|
||||
*/
|
||||
public String getProfileAsString(GetProfileString voidType) throws GCUBEFault{
|
||||
|
||||
try {
|
||||
return XMLUtils.DocumentToString(((ProfileResource)ProfileContext.getContext().getWSHome().find()).getProfile());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new GCUBEFault();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GCUBEServiceContext getServiceContext() {
|
||||
return ServiceContext.getContext();
|
||||
}
|
||||
}
|
|
@ -13,7 +13,6 @@ import org.gcube.common.core.utils.logging.GCUBELog;
|
|||
import org.gcube.informationsystem.registry.impl.contexts.FactoryContext;
|
||||
import org.gcube.informationsystem.registry.impl.contexts.ProfileContext;
|
||||
import org.gcube.informationsystem.registry.impl.contexts.ServiceContext;
|
||||
import org.gcube.informationsystem.registry.impl.state.ProfileResource;
|
||||
import org.gcube.informationsystem.registry.impl.state.RegistryFactoryResource;
|
||||
import org.gcube.informationsystem.registry.impl.state.Definitions.OperationType;
|
||||
import org.gcube.informationsystem.registry.stubs.CreateResourceMessage;
|
||||
|
@ -29,7 +28,7 @@ import org.gcube.informationsystem.registry.stubs.resourceregistration.CreateMes
|
|||
import org.gcube.informationsystem.registry.stubs.resourceregistration.RemoveMessage;
|
||||
import org.gcube.informationsystem.registry.stubs.resourceregistration.UpdateMessage;
|
||||
|
||||
import static org.gcube.informationsystem.registry.impl.state.Definitions.ResourceType;
|
||||
import static org.gcube.informationsystem.registry.impl.state.Definitions.ResourceMappings;
|
||||
|
||||
/**
|
||||
* Implementation of the <em>Registry Factory</em> portType
|
||||
|
@ -173,36 +172,6 @@ public class RegistryFactory extends GCUBEPortType {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the profile resource
|
||||
*
|
||||
* @param id the Resource ID
|
||||
* @return the resource or <tt>null</tt> if the resource has not been created yet
|
||||
*/
|
||||
protected synchronized ProfileResource getProfileResource(String id) {
|
||||
try {
|
||||
return (ProfileResource) ProfileContext.getContext().getWSHome()
|
||||
.find(ProfileContext.getContext().makeKey(id));
|
||||
} catch (Exception e) {
|
||||
logger.debug("A profile with the given id " + id+ " has not been created yet");
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a stateful resource with the given identifier exists
|
||||
*
|
||||
* @param id the resource's identifier
|
||||
* @return <tt>true</tt> if the resource exists, <tt>false</tt> otherwise
|
||||
*/
|
||||
protected synchronized boolean isResourceCreated(String id) {
|
||||
if (getProfileResource(id) != null)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the RegistryFactoryResource RPs for notification
|
||||
*
|
||||
|
@ -213,7 +182,7 @@ public class RegistryFactory extends GCUBEPortType {
|
|||
* @throws Exception if the update fails
|
||||
*/
|
||||
protected static synchronized void updateCounterInfo(String ID,
|
||||
ResourceType resType, OperationType opType, Calendar updateTime,
|
||||
ResourceMappings resType, OperationType opType, Calendar updateTime,
|
||||
String profile) throws Exception {
|
||||
//return;
|
||||
RegistryProperty property = new RegistryProperty();
|
||||
|
|
|
@ -18,14 +18,14 @@ import org.gcube.common.core.resources.GCUBEResource;
|
|||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
import org.gcube.informationsystem.registry.impl.contexts.ServiceContext;
|
||||
import org.gcube.informationsystem.registry.impl.contexts.ServiceContext.RegistryTopic;
|
||||
import org.gcube.informationsystem.registry.impl.filters.FilterManager;
|
||||
import org.gcube.informationsystem.registry.impl.filters.FilterExecutor.InvalidFilterException;
|
||||
import org.gcube.informationsystem.registry.impl.local.LocalNotifier;
|
||||
import org.gcube.informationsystem.registry.impl.purging.AvailablePurgers;
|
||||
import org.gcube.informationsystem.registry.impl.purging.GHNPurger;
|
||||
import org.gcube.informationsystem.registry.impl.purging.Purger;
|
||||
import org.gcube.informationsystem.registry.impl.postprocessing.purging.AvailablePurgers;
|
||||
import org.gcube.informationsystem.registry.impl.postprocessing.purging.GHNPurger;
|
||||
import org.gcube.informationsystem.registry.impl.postprocessing.purging.Purger;
|
||||
import org.gcube.informationsystem.registry.impl.preprocessing.filters.FilterManager;
|
||||
import org.gcube.informationsystem.registry.impl.preprocessing.filters.FilterExecutor.InvalidFilterException;
|
||||
import org.gcube.informationsystem.registry.impl.state.Definitions.OperationType;
|
||||
import org.gcube.informationsystem.registry.impl.state.Definitions.ResourceType;
|
||||
import org.gcube.informationsystem.registry.impl.state.Definitions.ResourceMappings;
|
||||
import org.gcube.informationsystem.registry.stubs.resourceregistration.CreateFault;
|
||||
import org.gcube.informationsystem.registry.stubs.resourceregistration.CreateMessage;
|
||||
import org.gcube.informationsystem.registry.stubs.resourceregistration.CreateResponse;
|
||||
|
@ -148,7 +148,7 @@ public class ResourceRegistration extends GCUBEPortType {
|
|||
}
|
||||
GCUBEResource resource;
|
||||
try {
|
||||
resource = ResourceType.valueOf(type).getResourceImplementation();
|
||||
resource = ResourceMappings.valueOf(type).getResourceImplementation();
|
||||
resource.load(new BufferedReader(new InputStreamReader( new ByteArrayInputStream(profile.getBytes("UTF-8")),"UTF-8")));
|
||||
//resource.addScope(ServiceContext.getContext().getScope());
|
||||
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package org.gcube.informationsystem.registry.impl.postprocessing.purging;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
|
||||
public class AvailablePurgers {
|
||||
|
||||
private static Map<String, Purger<?>> purgers = new HashMap<String, Purger<?>>();
|
||||
private static GCUBELog logger = new GCUBELog(AvailablePurgers.class);
|
||||
|
||||
public static void register(Purger<?> purger) {
|
||||
purgers.put(purger.getName(), purger);
|
||||
logger.debug ("Purger " + purger.getName() + " registered");
|
||||
}
|
||||
|
||||
public static Purger<?> getPurger(String purgerName) {
|
||||
return purgers.get(purgerName);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.informationsystem.registry.impl.purging;
|
||||
package org.gcube.informationsystem.registry.impl.postprocessing.purging;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.HashSet;
|
||||
|
@ -10,9 +10,7 @@ import org.gcube.common.core.informationsystem.client.ISClient;
|
|||
import org.gcube.common.core.informationsystem.client.QueryParameter;
|
||||
import org.gcube.common.core.informationsystem.client.XMLResult;
|
||||
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericQuery;
|
||||
import org.gcube.common.core.informationsystem.publisher.ISResourcePublisher;
|
||||
import org.gcube.common.core.resources.GCUBEHostingNode;
|
||||
import org.gcube.common.core.resources.GCUBEResource;
|
||||
import org.gcube.common.core.resources.GCUBERunningInstance;
|
||||
import org.gcube.common.core.scope.GCUBEScope;
|
||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
|
@ -61,8 +59,6 @@ public class GHNPurger implements Purger<GCUBEHostingNode> {
|
|||
}
|
||||
}
|
||||
|
||||
public void unregisterHostedRI() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> purge(String ghnid, GCUBEScope scope) throws Exception {
|
||||
|
@ -93,9 +89,8 @@ public class GHNPurger implements Purger<GCUBEHostingNode> {
|
|||
|
||||
|
||||
@Override
|
||||
public Class<GCUBEHostingNode> getResourceClass() {
|
||||
return GCUBEHostingNode.class;
|
||||
public String getName() {
|
||||
return GCUBEHostingNode.TYPE;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.informationsystem.registry.impl.purging;
|
||||
package org.gcube.informationsystem.registry.impl.postprocessing.purging;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -25,9 +25,9 @@ public interface Purger<RESOURCE extends GCUBEResource> {
|
|||
|
||||
|
||||
/**
|
||||
* Gets the actual type of RESOURCE
|
||||
* @return the type of RESOURCE
|
||||
* Gets the type of resource managed by the purgerE
|
||||
* @return the type
|
||||
*/
|
||||
public Class<RESOURCE> getResourceClass();
|
||||
public String getName();
|
||||
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package org.gcube.informationsystem.registry.impl.purging;
|
||||
package org.gcube.informationsystem.registry.impl.postprocessing.purging;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -16,6 +15,8 @@ import org.gcube.common.core.scope.GCUBEScope;
|
|||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
|
||||
/**
|
||||
* Purger for Running Instance resources. Cleanup all the resources related to
|
||||
* a just-deleted RI.
|
||||
*
|
||||
* @author Manuele Simi (ISTI-CNR)
|
||||
*
|
||||
|
@ -68,8 +69,8 @@ public class RIPurger implements Purger<GCUBERunningInstance> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Class<GCUBERunningInstance> getResourceClass() {
|
||||
return GCUBERunningInstance.class;
|
||||
public String getName() {
|
||||
return GCUBERunningInstance.TYPE;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.informationsystem.registry.impl.filters;
|
||||
package org.gcube.informationsystem.registry.impl.preprocessing.filters;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.informationsystem.registry.impl.filters;
|
||||
package org.gcube.informationsystem.registry.impl.preprocessing.filters;
|
||||
|
||||
public class Filter {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.informationsystem.registry.impl.filters;
|
||||
package org.gcube.informationsystem.registry.impl.preprocessing.filters;
|
||||
|
||||
import org.gcube.common.core.resources.GCUBEResource;
|
||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.informationsystem.registry.impl.filters;
|
||||
package org.gcube.informationsystem.registry.impl.preprocessing.filters;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.informationsystem.registry.impl.filters;
|
||||
package org.gcube.informationsystem.registry.impl.preprocessing.filters;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
|
@ -15,7 +15,7 @@ import org.gcube.common.core.resources.GCUBEGenericResource;
|
|||
import org.gcube.common.core.scope.GCUBEScope;
|
||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
import org.gcube.informationsystem.registry.impl.contexts.ServiceContext;
|
||||
import org.gcube.informationsystem.registry.impl.filters.Filter.FILTEROPERATION;
|
||||
import org.gcube.informationsystem.registry.impl.preprocessing.filters.Filter.FILTEROPERATION;
|
||||
import org.kxml2.io.KXmlParser;
|
||||
|
||||
public class FilterReader {
|
|
@ -1,10 +1,10 @@
|
|||
package org.gcube.informationsystem.registry.impl.filters;
|
||||
package org.gcube.informationsystem.registry.impl.preprocessing.filters;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.core.resources.GCUBEHostingNode;
|
||||
import org.gcube.common.core.resources.GCUBEResource;
|
||||
import org.gcube.informationsystem.registry.impl.filters.Filter.FILTEROPERATION;
|
||||
import org.gcube.informationsystem.registry.impl.preprocessing.filters.Filter.FILTEROPERATION;
|
||||
|
||||
/**
|
||||
* Filter for {@link GCUBEHostingNode} resource
|
|
@ -1,11 +1,11 @@
|
|||
package org.gcube.informationsystem.registry.impl.filters;
|
||||
package org.gcube.informationsystem.registry.impl.preprocessing.filters;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.core.resources.GCUBERunningInstance;
|
||||
import org.gcube.common.core.resources.GCUBEResource;
|
||||
import org.gcube.common.core.resources.runninginstance.Endpoint;
|
||||
import org.gcube.informationsystem.registry.impl.filters.Filter.FILTEROPERATION;
|
||||
import org.gcube.informationsystem.registry.impl.preprocessing.filters.Filter.FILTEROPERATION;
|
||||
|
||||
|
||||
/**
|
|
@ -1,18 +0,0 @@
|
|||
package org.gcube.informationsystem.registry.impl.purging;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class AvailablePurgers {
|
||||
|
||||
private static Map<Class<?>, Purger<?>> purgers = new HashMap<Class<?>, Purger<?>>();
|
||||
|
||||
public static void register(Purger<?> purger) {
|
||||
purgers.put(purger.getResourceClass(), purger);
|
||||
}
|
||||
|
||||
public static Purger<?> getPurger(Class<?> purgerClass) {
|
||||
return purgers.get(purgerClass);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
package org.gcube.informationsystem.registry.impl.resourcemanagement;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
import org.gcube.informationsystem.registry.impl.contexts.ProfileContext;
|
||||
import org.gcube.informationsystem.registry.impl.contexts.ServiceContext;
|
||||
|
||||
/**
|
||||
*
|
||||
* Manages the asynchronous deletion of temporary resources
|
||||
*
|
||||
* @author Lucio Lelii, Manuele Simi (ISTI-CNR)
|
||||
*
|
||||
*/
|
||||
public class EliminatePoolingThread extends Thread {
|
||||
|
||||
private final long sleepTime = (Long) ServiceContext.getContext().getProperty("temporaryResourceSweeperIntervalInMs");
|
||||
|
||||
private List<Pair> stack = Collections.synchronizedList(new LinkedList<Pair>());
|
||||
|
||||
private static GCUBELog logger = new GCUBELog(EliminatePoolingThread.class);
|
||||
|
||||
public void run() {
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
Thread.sleep(sleepTime);
|
||||
} catch (InterruptedException e) {}
|
||||
|
||||
try {
|
||||
synchronized (stack) {
|
||||
int numRes = stack.size();
|
||||
LinkedList<Pair> undeletedResources = this.checkResources();
|
||||
logger.debug("cannot destroy " + undeletedResources.size() + " resources, retrying later");
|
||||
logger.debug("destroyed " + (numRes - undeletedResources.size()) + " resources ");
|
||||
stack.addAll(undeletedResources);
|
||||
} // end synchronized block
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Cannot continue with thread Excecution " + e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized List<Pair> getStack() {
|
||||
return this.stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks and deletes expired temporary resources
|
||||
* @return the list of still living resources
|
||||
*/
|
||||
private LinkedList<Pair> checkResources() {
|
||||
|
||||
LinkedList<Pair> tmpStack = new LinkedList<Pair>();
|
||||
long timestamp = System.currentTimeMillis();
|
||||
|
||||
while (stack.size() > 0) {
|
||||
Pair c = stack.remove(stack.size() - 1);
|
||||
logger.trace("checking resource for deletion " + c.resource.getID());
|
||||
logger.trace("timenstamp now: " + timestamp + ", resource lifetime: " + c.lifetime);
|
||||
if (timestamp >= c.lifetime) {
|
||||
try {
|
||||
logger.debug("temporary resource " + c.resource.getID() + " is going to be deleted");
|
||||
ProfileContext.getContext().getWSHome().remove(c.resource.getID());
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
tmpStack.offer(c);// re-insert the resource in the list
|
||||
}
|
||||
} else {
|
||||
tmpStack.offer(c); // re-insert the resource in the list
|
||||
}
|
||||
}
|
||||
return tmpStack;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
package org.gcube.informationsystem.registry.impl.resourcemanagement;
|
||||
|
||||
import org.gcube.informationsystem.registry.impl.state.ProfileResource;
|
||||
|
||||
/**
|
||||
*
|
||||
* Maintain a {@link ProfileResource} and related lifetime association
|
||||
*
|
||||
* @author Manuele Simi (ISTI-CNR)
|
||||
*
|
||||
*/
|
||||
public class Pair {
|
||||
|
||||
public long lifetime;
|
||||
public ProfileResource resource;
|
||||
|
||||
public Pair(long lifetime, ProfileResource resource){
|
||||
this.lifetime = lifetime;
|
||||
this.resource = resource;
|
||||
}
|
||||
|
||||
public boolean equals(Object o){
|
||||
Pair objectCouple = (Pair) o;
|
||||
return objectCouple.resource.equals(this.resource);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
package org.gcube.informationsystem.registry.impl.resourcemanagement;
|
||||
|
||||
import java.util.List;
|
||||
import org.gcube.common.core.informationsystem.notifier.ISNotifier;
|
||||
import org.gcube.common.core.contexts.GHNContext;
|
||||
import org.gcube.common.core.scope.GCUBEScope;
|
||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
import org.gcube.informationsystem.registry.impl.contexts.FactoryContext;
|
||||
import org.gcube.informationsystem.registry.impl.contexts.ServiceContext;
|
||||
import org.globus.wsrf.Topic;
|
||||
|
||||
/**
|
||||
* Registration Thread class
|
||||
*
|
||||
* @author Andrea Manzi (ISTI-CNR)
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class RegistrationThread implements Runnable {
|
||||
|
||||
private static GCUBELog logger = new GCUBELog(RegistrationThread.class);
|
||||
|
||||
private List<? extends Topic> topics;
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*
|
||||
* @param qname
|
||||
* an Array list of RP qname
|
||||
* @throws Exception
|
||||
* Exception
|
||||
*/
|
||||
public RegistrationThread(List<? extends Topic> topics) throws Exception {
|
||||
this.topics = topics;
|
||||
}
|
||||
|
||||
|
||||
public void run() {
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
// This is the time interval
|
||||
Thread.sleep(10000);
|
||||
} catch (InterruptedException e) {}
|
||||
try {
|
||||
|
||||
ISNotifier notifier = GHNContext.getImplementation(ISNotifier.class);
|
||||
notifier.registerISNotification(FactoryContext.getContext().getEPR(), topics, ServiceContext.getContext(),
|
||||
ServiceContext.getContext().getInstance().getScopes().values().toArray(new GCUBEScope[0]));
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
logger.error("Error starting registration: Retrying in 10 seconds");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
package org.gcube.informationsystem.registry.impl.resources;
|
||||
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import org.gcube.common.core.resources.GCUBEHostingNode;
|
||||
import org.gcube.common.core.resources.GCUBEResource;
|
||||
|
||||
/**
|
||||
* A to-be-registered {@link GCUBEResource} passed to the ISRegistry
|
||||
*
|
||||
* @author Manuele Simi (ISTI-CNR)
|
||||
*
|
||||
*/
|
||||
public class GCUBERegisteredResource {
|
||||
|
||||
|
||||
protected GCUBEResource resource;
|
||||
|
||||
Document dom = null;
|
||||
|
||||
public GCUBERegisteredResource (GCUBEResource resource) throws Exception {
|
||||
this.resource = resource;
|
||||
this.parse();
|
||||
}
|
||||
|
||||
public String getID() {
|
||||
return this.resource.getID();
|
||||
}
|
||||
|
||||
/**
|
||||
* States if the resource is a temporary resource, i.e. must be destroyed after its registration
|
||||
* @return
|
||||
*/
|
||||
public boolean isTemporary() {
|
||||
if (resource.getType().compareTo(GCUBEHostingNode.TYPE) == 0)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
private void parse() throws Exception {
|
||||
StringWriter writer = new StringWriter();
|
||||
try {
|
||||
resource.store(writer);
|
||||
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setNamespaceAware(true);
|
||||
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
|
||||
StringReader reader = new StringReader(writer.toString().substring(writer.toString().indexOf("?>") + 2, writer.toString().length()));
|
||||
|
||||
InputSource source = new InputSource(reader);
|
||||
|
||||
this.dom = builder.parse(source);
|
||||
|
||||
} catch (Exception e1) {
|
||||
throw new Exception("Unable to parse the resource");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the XML Document representation of the resouce
|
||||
*/
|
||||
public Document getAsDOM() {
|
||||
return this.dom;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the source resource
|
||||
*/
|
||||
public GCUBEResource getSource() {
|
||||
return this.resource;
|
||||
}
|
||||
}
|
|
@ -1,8 +1,6 @@
|
|||
package org.gcube.informationsystem.registry.impl.state;
|
||||
|
||||
import org.gcube.common.core.contexts.GHNContext;
|
||||
import org.gcube.common.core.resources.GCUBECS;
|
||||
import org.gcube.common.core.resources.GCUBECSInstance;
|
||||
import org.gcube.common.core.resources.GCUBECollection;
|
||||
import org.gcube.common.core.resources.GCUBEExternalRunningInstance;
|
||||
import org.gcube.common.core.resources.GCUBEGenericResource;
|
||||
|
@ -23,7 +21,7 @@ public class Definitions {
|
|||
|
||||
|
||||
/** The Resource Types */
|
||||
public static enum ResourceType {
|
||||
public static enum ResourceMappings {
|
||||
RunningInstance() {public GCUBEResource getResourceImplementation() throws Exception {return GHNContext.getImplementation(GCUBERunningInstance.class);}},
|
||||
ExternalRunningInstance() {public GCUBEResource getResourceImplementation() throws Exception {return GHNContext.getImplementation(GCUBEExternalRunningInstance.class);}},
|
||||
Service() {public GCUBEResource getResourceImplementation() throws Exception {return GHNContext.getImplementation(GCUBEService.class);}},
|
||||
|
|
|
@ -1,127 +0,0 @@
|
|||
package org.gcube.informationsystem.registry.impl.state;
|
||||
|
||||
import org.gcube.common.core.contexts.GHNContext;
|
||||
import org.gcube.common.core.informationsystem.publisher.ISPublisher;
|
||||
import org.gcube.common.core.resources.GCUBEResource;
|
||||
import org.gcube.common.core.state.GCUBEWSResource;
|
||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
import org.gcube.informationsystem.registry.impl.resources.GCUBERegisteredResource;
|
||||
|
||||
import org.globus.wsrf.ResourceException;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
/**
|
||||
* Profile Stateful resource
|
||||
*
|
||||
* @author Andrea Manzi, Lucio Lelii, Manuele Simi (ISTI-CNR)
|
||||
*
|
||||
*/
|
||||
public class ProfileResource extends GCUBEWSResource {
|
||||
|
||||
private static GCUBELog logger = new GCUBELog(ProfileResource.class.getName());
|
||||
|
||||
protected GCUBEResource gCubeResource;
|
||||
|
||||
protected static final String ProfileRP = "Profile";
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*/
|
||||
public ProfileResource() {};
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected String[] getPropertyNames() {
|
||||
return new String[] { ProfileRP };
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the resource
|
||||
*
|
||||
* @param params
|
||||
* Object
|
||||
* @throws ResourceException
|
||||
* if resource is missing
|
||||
*/
|
||||
@Override
|
||||
public void initialise(Object... params) throws ResourceException {
|
||||
GCUBERegisteredResource resource;
|
||||
try {
|
||||
resource = new GCUBERegisteredResource((GCUBEResource) params[0]);
|
||||
} catch (Exception e) {
|
||||
throw new ResourceException("Invalid GCUBEResource");
|
||||
}
|
||||
logger.debug("initializing resource " + resource.getID());
|
||||
|
||||
this.setProfile(resource.getAsDOM());
|
||||
// this.setNotificationProfile(dom);
|
||||
this.setGCubeResource(resource.getSource());
|
||||
|
||||
if (resource.isTemporary())
|
||||
this.setTerminationTime(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets Profile
|
||||
*
|
||||
* @param profile the profile
|
||||
*/
|
||||
public void setProfile(Document profile) {
|
||||
this.getResourcePropertySet().get(ProfileRP).clear();
|
||||
this.getResourcePropertySet().get(ProfileRP).add(profile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Profile
|
||||
*
|
||||
* @return the profile
|
||||
*/
|
||||
public Document getProfile() {
|
||||
return (Document) this.getResourcePropertySet().get(ProfileRP).get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the source {@link GCUBEResource}
|
||||
*
|
||||
* @return the resource
|
||||
*/
|
||||
public GCUBEResource getGCubeResource() {
|
||||
return this.gCubeResource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source {@link GCUBEResource}
|
||||
*
|
||||
* @param resource the resource
|
||||
*/
|
||||
public void setGCubeResource(GCUBEResource resource) {
|
||||
this.gCubeResource = resource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the resource
|
||||
*
|
||||
* @param resource
|
||||
* the resource to update
|
||||
* @throws Exception
|
||||
* if something goes wrong
|
||||
*/
|
||||
public void updateResource(GCUBEResource resource) throws Exception {
|
||||
GCUBERegisteredResource regResource = new GCUBERegisteredResource(resource);
|
||||
this.setProfile(regResource.getAsDOM());
|
||||
this.setGCubeResource(resource);
|
||||
this.store();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.common.core.state.GCUBEWSResource#getPublisher()
|
||||
*/
|
||||
@Override
|
||||
protected ISPublisher getPublisher() throws Exception {
|
||||
return GHNContext.getImplementation(ISPublisher.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package org.gcube.informationsystem.registry.impl.state;
|
||||
|
||||
import org.gcube.common.core.contexts.GCUBEStatefulPortTypeContext;
|
||||
|
||||
import org.gcube.common.core.state.GCUBEWSHome;
|
||||
import org.gcube.informationsystem.registry.impl.contexts.ProfileContext;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author lucio
|
||||
*
|
||||
*/
|
||||
public class ProfileResourceHome extends GCUBEWSHome {
|
||||
|
||||
/** {@inheritDoc}*/
|
||||
public GCUBEStatefulPortTypeContext getPortTypeContext() {
|
||||
return ProfileContext.getContext();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue