git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@7222 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7f0a5355d8
commit
97279c10ad
|
@ -32,12 +32,12 @@
|
||||||
</Dependencies>
|
</Dependencies>
|
||||||
<GARArchive>org.gcube.informationsystem.registry.gar</GARArchive>
|
<GARArchive>org.gcube.informationsystem.registry.gar</GARArchive>
|
||||||
<PortType>
|
<PortType>
|
||||||
<Name>gcube/informationsystem/registry/registryFactory</Name>
|
<Name>gcube/informationsystem/registry/RegistryFactory</Name>
|
||||||
<Security/>
|
<Security/>
|
||||||
<WSDL/>
|
<WSDL/>
|
||||||
</PortType>
|
</PortType>
|
||||||
<PortType>
|
<PortType>
|
||||||
<Name>gcube/informationsystem/registry/registry</Name>
|
<Name>gcube/informationsystem/registry/Registry</Name>
|
||||||
<Security/>
|
<Security/>
|
||||||
<WSDL/>
|
<WSDL/>
|
||||||
</PortType>
|
</PortType>
|
||||||
|
|
|
@ -13,7 +13,10 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.axis.components.uuid.UUIDGen;
|
import org.apache.axis.components.uuid.UUIDGen;
|
||||||
import org.apache.axis.components.uuid.UUIDGenFactory;
|
import org.apache.axis.components.uuid.UUIDGenFactory;
|
||||||
|
import org.gcube.common.core.contexts.GHNContext;
|
||||||
import org.gcube.common.core.faults.GCUBEFault;
|
import org.gcube.common.core.faults.GCUBEFault;
|
||||||
|
import org.gcube.common.core.informationsystem.notifier.ISNotifier;
|
||||||
|
import org.gcube.common.core.informationsystem.publisher.ISPublisherException;
|
||||||
import org.gcube.common.core.resources.GCUBEHostingNode;
|
import org.gcube.common.core.resources.GCUBEHostingNode;
|
||||||
import org.gcube.common.core.resources.GCUBEResource;
|
import org.gcube.common.core.resources.GCUBEResource;
|
||||||
import org.gcube.common.core.resources.service.Package.GHNRequirement;
|
import org.gcube.common.core.resources.service.Package.GHNRequirement;
|
||||||
|
@ -172,8 +175,13 @@ public class RegistryFactory{
|
||||||
logger.debug(resource.getID()+" Creating the stateful resource for " + resource.getID());
|
logger.debug(resource.getID()+" Creating the stateful resource for " + resource.getID());
|
||||||
ProfileResource presource = (ProfileResource) ProfileContext.getContext().getWSHome().create(ProfileContext.getContext().makeKey(resource.getID()),resource);
|
ProfileResource presource = (ProfileResource) ProfileContext.getContext().getWSHome().create(ProfileContext.getContext().makeKey(resource.getID()),resource);
|
||||||
presource.getPersistenceDelegate().store(presource);
|
presource.getPersistenceDelegate().store(presource);
|
||||||
if (resource.getType().compareTo(GCUBEHostingNode.TYPE)!=0)
|
if (resource.getType().compareTo(GCUBEHostingNode.TYPE)!=0){
|
||||||
EliminatePoolingThread.getStack().add(presource);
|
GCUBEScope tmpScope= ServiceContext.getContext().getScope().getType() == GCUBEScope.Type.VRE ? ServiceContext.getContext().getScope().getEnclosingScope() : ServiceContext.getContext().getScope();
|
||||||
|
if(!ServiceContext.threadTable.get(tmpScope.getName()).getStack().contains(presource)){
|
||||||
|
ServiceContext.threadTable.get(tmpScope.getName()).getStack().add(presource);
|
||||||
|
logger.trace("Adding resource to EliminatePoolingThread "+presource.getGCubeResource().getID());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
String msg = "Error creating Resource";
|
String msg = "Error creating Resource";
|
||||||
|
@ -242,7 +250,15 @@ public class RegistryFactory{
|
||||||
try {
|
try {
|
||||||
resource = ResourceType.valueOf(mess.getType()).getResourceClass();
|
resource = ResourceType.valueOf(mess.getType()).getResourceClass();
|
||||||
resource.load(new StringReader(xmlProfile));
|
resource.load(new StringReader(xmlProfile));
|
||||||
getProfileResource(ID).updateResource(resource);
|
ProfileResource pr= getProfileResource(ID);
|
||||||
|
pr.updateResource(resource);
|
||||||
|
if (resource.getType().compareTo(GCUBEHostingNode.TYPE)!=0){
|
||||||
|
GCUBEScope tmpScope= ServiceContext.getContext().getScope().getType() == GCUBEScope.Type.VRE ? ServiceContext.getContext().getScope().getEnclosingScope() : ServiceContext.getContext().getScope();
|
||||||
|
if(!ServiceContext.threadTable.get(tmpScope.getName()).getStack().contains(pr)){
|
||||||
|
ServiceContext.threadTable.get(tmpScope.getName()).getStack().add(pr);
|
||||||
|
logger.trace("Adding resource to EliminatePoolingThread "+pr.getGCubeResource().getID());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
logger.error("Error updating profile for ID "+ e);
|
logger.error("Error updating profile for ID "+ e);
|
||||||
|
@ -314,6 +330,7 @@ public class RegistryFactory{
|
||||||
try{
|
try{
|
||||||
|
|
||||||
ProfileContext.getContext().getWSHome().remove(ProfileContext.getContext().makeKey(ID));
|
ProfileContext.getContext().getWSHome().remove(ProfileContext.getContext().makeKey(ID));
|
||||||
|
|
||||||
logger.info(" Resource Destroyed");
|
logger.info(" Resource Destroyed");
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
@ -334,6 +351,7 @@ public class RegistryFactory{
|
||||||
logger.warn("Error updating counting info for resource with ID " + ID ,e);
|
logger.warn("Error updating counting info for resource with ID " + ID ,e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new RemoveResourceResponse();
|
return new RemoveResourceResponse();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.gcube.informationsystem.registry.impl.contexts;
|
package org.gcube.informationsystem.registry.impl.contexts;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Hashtable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.gcube.common.core.contexts.GCUBEServiceContext;
|
import org.gcube.common.core.contexts.GCUBEServiceContext;
|
||||||
import org.gcube.common.core.contexts.GHNContext;
|
import org.gcube.common.core.contexts.GHNContext;
|
||||||
|
@ -22,6 +23,7 @@ import org.gcube.common.core.utils.handlers.GCUBEScheduledHandler;
|
||||||
import org.gcube.informationsystem.registry.impl.RegistryFactory;
|
import org.gcube.informationsystem.registry.impl.RegistryFactory;
|
||||||
import org.gcube.informationsystem.registry.impl.core.RegistryConfiguration.ROOT_SERVICES;
|
import org.gcube.informationsystem.registry.impl.core.RegistryConfiguration.ROOT_SERVICES;
|
||||||
import org.gcube.informationsystem.registry.impl.state.RegistryFactoryResource;
|
import org.gcube.informationsystem.registry.impl.state.RegistryFactoryResource;
|
||||||
|
import org.gcube.informationsystem.registry.impl.util.EliminatePoolingThread;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,6 +36,8 @@ public class ServiceContext extends GCUBEServiceContext {
|
||||||
|
|
||||||
public static final String JNDI_NAME = "gcube/informationsystem/registry";
|
public static final String JNDI_NAME = "gcube/informationsystem/registry";
|
||||||
|
|
||||||
|
public static Hashtable<String, EliminatePoolingThread> threadTable= new Hashtable<String, EliminatePoolingThread>();
|
||||||
|
|
||||||
protected static final ServiceContext cache = new ServiceContext();
|
protected static final ServiceContext cache = new ServiceContext();
|
||||||
|
|
||||||
protected ISClient client = null;
|
protected ISClient client = null;
|
||||||
|
@ -104,6 +108,7 @@ public class ServiceContext extends GCUBEServiceContext {
|
||||||
protected void onReady() throws Exception {
|
protected void onReady() throws Exception {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//switch to the production mode if needed
|
//switch to the production mode if needed
|
||||||
if (GHNContext.getContext().getMode() == Mode.ROOT)
|
if (GHNContext.getContext().getMode() == Mode.ROOT)
|
||||||
GHNContext.getContext().setMode(Mode.CONNECTED);
|
GHNContext.getContext().setMode(Mode.CONNECTED);
|
||||||
|
@ -111,6 +116,13 @@ public class ServiceContext extends GCUBEServiceContext {
|
||||||
//creates the single RegistryResource used to raise notifications about profiles' changes
|
//creates the single RegistryResource used to raise notifications about profiles' changes
|
||||||
logger.info("Scheduling IS-Registry notification resource...");
|
logger.info("Scheduling IS-Registry notification resource...");
|
||||||
|
|
||||||
|
for (GCUBEScope scope: ServiceContext.getContext().getStartScopes()){
|
||||||
|
EliminatePoolingThread ept= new EliminatePoolingThread();
|
||||||
|
ServiceContext.getContext().setScope(ept, scope);
|
||||||
|
ept.start();
|
||||||
|
threadTable.put(scope.getName(), ept);
|
||||||
|
}
|
||||||
|
|
||||||
NotificationResourceScheduler scheduler = new NotificationResourceScheduler(20, GCUBEScheduledHandler.Mode.LAZY);
|
NotificationResourceScheduler scheduler = new NotificationResourceScheduler(20, GCUBEScheduledHandler.Mode.LAZY);
|
||||||
scheduler.setHandled(new GCUBEHandler(){
|
scheduler.setHandled(new GCUBEHandler(){
|
||||||
public void run() throws Exception {
|
public void run() throws Exception {
|
||||||
|
|
|
@ -20,6 +20,7 @@ import org.gcube.common.core.resources.GCUBEHostingNode;
|
||||||
import org.gcube.common.core.resources.GCUBEResource;
|
import org.gcube.common.core.resources.GCUBEResource;
|
||||||
import org.gcube.common.core.resources.GCUBERunningInstance;
|
import org.gcube.common.core.resources.GCUBERunningInstance;
|
||||||
import org.gcube.common.core.resources.GCUBEService;
|
import org.gcube.common.core.resources.GCUBEService;
|
||||||
|
import org.gcube.common.core.scope.GCUBEScope;
|
||||||
import org.gcube.common.core.state.GCUBEWSResource;
|
import org.gcube.common.core.state.GCUBEWSResource;
|
||||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||||
import org.gcube.informationsystem.registry.impl.RegistryFactory;
|
import org.gcube.informationsystem.registry.impl.RegistryFactory;
|
||||||
|
@ -43,9 +44,7 @@ public class ProfileResource extends GCUBEWSResource {
|
||||||
|
|
||||||
private ISPublisher publisher = null;
|
private ISPublisher publisher = null;
|
||||||
|
|
||||||
private ISNotifier notifier= null;
|
//private ISNotifier notifier= null;
|
||||||
|
|
||||||
ArrayList<SimpleTopic> listQname = new ArrayList<SimpleTopic>();
|
|
||||||
|
|
||||||
protected static final String NotificationProfileRP="NotificationProfile";
|
protected static final String NotificationProfileRP="NotificationProfile";
|
||||||
|
|
||||||
|
@ -110,6 +109,7 @@ public class ProfileResource extends GCUBEWSResource {
|
||||||
|
|
||||||
if (hasToLive(resource)) this.setTerminationTime(null);
|
if (hasToLive(resource)) this.setTerminationTime(null);
|
||||||
|
|
||||||
|
/*
|
||||||
if (hasToLive(resource)) {
|
if (hasToLive(resource)) {
|
||||||
//registration of Topic To IS-Notifier
|
//registration of Topic To IS-Notifier
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ public class ProfileResource extends GCUBEWSResource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -226,11 +226,11 @@ public class ProfileResource extends GCUBEWSResource {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if (RegistryFactory.notificationMap.contains(this.getID()))
|
if (RegistryFactory.notificationMap.contains(this.getID()))
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
notifier = GHNContext.getImplementation(ISNotifier.class);
|
||||||
notifier.unregisterISNotification(this.getEPR(),listQname,ServiceContext.getContext());
|
notifier.unregisterISNotification(this.getEPR(),listQname,ServiceContext.getContext());
|
||||||
} catch (ISPublisherException e) {
|
} catch (ISPublisherException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -241,10 +241,11 @@ public class ProfileResource extends GCUBEWSResource {
|
||||||
synchronized(RegistryFactory.notificationMap) {
|
synchronized(RegistryFactory.notificationMap) {
|
||||||
RegistryFactory.notificationMap.remove(this.getID());
|
RegistryFactory.notificationMap.remove(this.getID());
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
try {
|
try {
|
||||||
publisher.removeWSResource(this,ServiceContext.getContext().getScope());
|
publisher.removeWSResource(this,ServiceContext.getContext().getScope());
|
||||||
|
System.out.println(" "+this.getResourcePropertySet().getScope().get(0));
|
||||||
} catch (ISPublisherException e) {
|
} catch (ISPublisherException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,16 +7,19 @@ import java.util.List;
|
||||||
|
|
||||||
import org.gcube.common.core.contexts.GHNContext;
|
import org.gcube.common.core.contexts.GHNContext;
|
||||||
import org.gcube.common.core.informationsystem.client.ISClient;
|
import org.gcube.common.core.informationsystem.client.ISClient;
|
||||||
|
import org.gcube.common.core.informationsystem.client.XMLResult;
|
||||||
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericQuery;
|
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericQuery;
|
||||||
import org.gcube.common.core.scope.GCUBEScope;
|
|
||||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||||
|
import org.gcube.informationsystem.registry.impl.RegistryFactory;
|
||||||
|
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.ProfileResource;
|
||||||
|
|
||||||
public class EliminatePoolingThread extends Thread {
|
public class EliminatePoolingThread extends Thread {
|
||||||
|
|
||||||
private static List<ProfileResource> stack = Collections.synchronizedList(new LinkedList<ProfileResource>());
|
private List<ProfileResource> stack = Collections.synchronizedList(new LinkedList<ProfileResource>());
|
||||||
|
|
||||||
private static GCUBELog logger = new GCUBELog(EliminatePoolingThread.class.getName());
|
private static GCUBELog logger = new GCUBELog(RegistryFactory.class.getName());
|
||||||
|
|
||||||
public void run(){
|
public void run(){
|
||||||
boolean noErrors= true;
|
boolean noErrors= true;
|
||||||
|
@ -36,9 +39,15 @@ public class EliminatePoolingThread extends Thread {
|
||||||
ProfileResource p;
|
ProfileResource p;
|
||||||
synchronized (stack) {
|
synchronized (stack) {
|
||||||
int numRes= stack.size();
|
int numRes= stack.size();
|
||||||
while ((p=stack.remove(stack.size()-1))!=null){
|
while (stack.size()>0){
|
||||||
query.setExpression("declare namespace is = 'http://gcube-system.org/namespaces/informationsystem/registry';for $result in collection(\"/db/Profile\")//Document/Data/is:Profile/Resource where $result/ID/string() eq '"+p.getID().getValue()+"' return true");
|
p=stack.remove(stack.size()-1);
|
||||||
if (client.execute(query, GCUBEScope.getScope(p.getResourcePropertySet().getScope().get(0))).size()>0) p.remove();
|
query.setExpression("declare namespace is = 'http://gcube-system.org/namespaces/informationsystem/registry';" +
|
||||||
|
"for $result in collection(\"/db/Profiles\")//Document/Data/is:Profile/Resource where ($result/ID/string() eq '"+p.getGCubeResource().getID()+"') return 1");
|
||||||
|
List<XMLResult> list= client.execute(query, ServiceContext.getContext().getScope());
|
||||||
|
|
||||||
|
if (list.size()>0) try {
|
||||||
|
ProfileContext.getContext().getWSHome().remove(p.getID());
|
||||||
|
}catch(Exception e){e.printStackTrace();tmpStack.offer(p);}
|
||||||
else tmpStack.offer(p);
|
else tmpStack.offer(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,10 +55,11 @@ public class EliminatePoolingThread extends Thread {
|
||||||
logger.debug("destroyed "+(numRes-tmpStack.size())+" resources ");
|
logger.debug("destroyed "+(numRes-tmpStack.size())+" resources ");
|
||||||
stack.addAll(tmpStack);
|
stack.addAll(tmpStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Cannot continue with thread Excecution "+e);
|
logger.error("Cannot continue with thread Excecution "+e);
|
||||||
|
e.printStackTrace();
|
||||||
noErrors=false;
|
noErrors=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,8 +67,8 @@ public class EliminatePoolingThread extends Thread {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static synchronized List<ProfileResource> getStack(){
|
public synchronized List<ProfileResource> getStack(){
|
||||||
return stack;
|
return this.stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue