Classes of living resources configurable via JNDI
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@25579 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7ddab7f37b
commit
d8315a8a91
|
@ -3,30 +3,28 @@
|
|||
|
||||
<service name="gcube/informationsystem/registry">
|
||||
|
||||
<environment
|
||||
name="configDir"
|
||||
value="@config.dir@"
|
||||
type="java.lang.String"
|
||||
override="false" />
|
||||
|
||||
<!-- Lifetime for temporary resources, after this period temporary resources are destroyed-->
|
||||
<environment
|
||||
name="temporaryResourceLifetimeInMs"
|
||||
value="480000"
|
||||
type="java.lang.Long"
|
||||
override="false" />
|
||||
|
||||
<environment
|
||||
name="temporaryResourceSweeperIntervalInMs"
|
||||
value="480000"
|
||||
type="java.lang.Long"
|
||||
<environment name="configDir" value="@config.dir@" type="java.lang.String"
|
||||
override="false" />
|
||||
|
||||
<!--
|
||||
<environment
|
||||
name="startScopes"
|
||||
value=""
|
||||
type="java.lang.String"
|
||||
GCUBEResources that are not considered temporary, i.e. they are not automatically
|
||||
destroyed after the 'temporaryResourceLifetimeInMs' period
|
||||
-->
|
||||
<environment name="livingResourceTypes" value="GHN,RunningInstance"
|
||||
type="java.lang.String" override="false" />
|
||||
|
||||
<!--
|
||||
Lifetime for temporary resources, after this period temporary
|
||||
resources are destroyed
|
||||
-->
|
||||
<environment name="temporaryResourceLifetimeInMs" value="480000"
|
||||
type="java.lang.Long" override="false" />
|
||||
|
||||
<environment name="temporaryResourceSweeperIntervalInMs"
|
||||
value="480000" type="java.lang.Long" override="false" />
|
||||
|
||||
<!--
|
||||
<environment name="startScopes" value="" type="java.lang.String"
|
||||
override="false" />
|
||||
-->
|
||||
|
||||
|
@ -34,20 +32,15 @@
|
|||
|
||||
<service name="gcube/informationsystem/registry/Registry">
|
||||
|
||||
<environment
|
||||
name="name"
|
||||
value="Registry"
|
||||
type="java.lang.String"
|
||||
<environment name="name" value="Registry" type="java.lang.String"
|
||||
override="false" />
|
||||
|
||||
<environment
|
||||
name="RPDName"
|
||||
value="ProfileResourceProperties"
|
||||
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">
|
||||
<resource name="publicationProfile"
|
||||
type="org.gcube.common.core.state.GCUBEPublicationProfile">
|
||||
<resourceParams>
|
||||
<parameter>
|
||||
<name>factory</name>
|
||||
|
@ -64,27 +57,28 @@
|
|||
</resourceParams>
|
||||
</resource>
|
||||
|
||||
<resource name="home" type="org.gcube.informationsystem.registry.impl.state.ProfileResourceHome">
|
||||
<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>
|
||||
<value>org.gcube.informationsystem.registry.impl.state.ProfileResource
|
||||
</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>persistenceDelegateClass</name>
|
||||
<value>org.gcube.informationsystem.registry.impl.persistence.RegistryPersistenceDelegate</value>
|
||||
<value>org.gcube.informationsystem.registry.impl.persistence.RegistryPersistenceDelegate
|
||||
</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>sweeperDelay</name>
|
||||
<value>10000</value>
|
||||
</parameter>
|
||||
|
||||
</resourceParams>
|
||||
|
||||
</resource>
|
||||
|
@ -95,39 +89,14 @@
|
|||
|
||||
<service name="gcube/informationsystem/registry/RegistryFactory">
|
||||
|
||||
<environment
|
||||
name="name"
|
||||
value="RegistryFactory"
|
||||
type="java.lang.String"
|
||||
<environment name="name" value="RegistryFactory" type="java.lang.String"
|
||||
override="false" />
|
||||
|
||||
<environment
|
||||
name="RPDName"
|
||||
value="RegistryFactoryResourceProperties"
|
||||
type="java.lang.String"
|
||||
override="false"/>
|
||||
<environment name="RPDName" value="RegistryFactoryResourceProperties"
|
||||
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>pull</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>fileName</name>
|
||||
<value>registrationFactory.xml</value>
|
||||
</parameter>
|
||||
</resourceParams>
|
||||
</resource> -->
|
||||
|
||||
<resource name="home" type="org.gcube.informationsystem.registry.impl.state.RegistryFactoryResourceHome">
|
||||
<resource name="home"
|
||||
type="org.gcube.informationsystem.registry.impl.state.RegistryFactoryResourceHome">
|
||||
<resourceParams>
|
||||
<parameter>
|
||||
<name>factory</name>
|
||||
|
@ -135,11 +104,13 @@
|
|||
</parameter>
|
||||
<parameter>
|
||||
<name>resourceClass</name>
|
||||
<value>org.gcube.informationsystem.registry.impl.state.RegistryFactoryResource</value>
|
||||
<value>org.gcube.informationsystem.registry.impl.state.RegistryFactoryResource
|
||||
</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>persistenceDelegateClass</name>
|
||||
<value>org.gcube.informationsystem.registry.impl.persistence.RegistryFactoryPersistenceDelegate</value>
|
||||
<value>org.gcube.informationsystem.registry.impl.persistence.RegistryFactoryPersistenceDelegate
|
||||
</value>
|
||||
</parameter>
|
||||
|
||||
</resourceParams>
|
||||
|
|
|
@ -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>1.3.3</Version>
|
||||
<Version>1.4.0</Version>
|
||||
<Mandatory level="VO"/>
|
||||
<Shareable level="VO"/>
|
||||
<GHNRequirements>
|
||||
|
|
|
@ -7,7 +7,11 @@ import java.io.StringReader;
|
|||
import java.io.StringWriter;
|
||||
import java.lang.reflect.Method;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.axis.components.uuid.UUIDGen;
|
||||
import org.apache.axis.components.uuid.UUIDGenFactory;
|
||||
import org.gcube.common.core.contexts.GCUBEServiceContext;
|
||||
|
@ -50,19 +54,28 @@ public class RegistryFactory extends GCUBEPortType {
|
|||
/** Name of temporaryResourceLifetimeInMs JNDI environment. */
|
||||
private static final String LIFETIME_JNDI_NAME = "temporaryResourceLifetimeInMs";
|
||||
|
||||
/** Name of Living Resource Types JNDI environment. */
|
||||
private static final String LIVINGTYPES_JNDI_NAME = "livingResourceTypes";
|
||||
|
||||
/**
|
||||
* Lifetime of temporary resources
|
||||
*/
|
||||
private static long temporaryResourceLifetimeInMs = 120000;
|
||||
|
||||
/**
|
||||
* Lifetime of temporary resources
|
||||
*/
|
||||
private static List<String> livingResourceTypes;
|
||||
|
||||
/** The UUIDGen */
|
||||
private static final UUIDGen uuidgen = UUIDGenFactory.getUUIDGen();
|
||||
|
||||
/** Object logger */
|
||||
protected final GCUBELog logger = new GCUBELog(RegistryFactory.class);
|
||||
|
||||
enum OperationType {create, update, destroy};
|
||||
|
||||
enum OperationType {
|
||||
create, update, destroy
|
||||
};
|
||||
|
||||
/** the key used to label the Factory Resource */
|
||||
public static final String NOTIFICATOR_RESOURCE_KEY = "RegistryResource";
|
||||
|
@ -74,21 +87,26 @@ public class RegistryFactory extends GCUBEPortType {
|
|||
protected void onInitialisation() throws Exception {
|
||||
temporaryResourceLifetimeInMs = (Long) ServiceContext.getContext().getProperty(LIFETIME_JNDI_NAME);
|
||||
logger.info("Temporary resources lifetime = "+ temporaryResourceLifetimeInMs);
|
||||
try {
|
||||
temporaryResourceLifetimeInMs = (Long) ServiceContext.getContext().getProperty(LIFETIME_JNDI_NAME);
|
||||
livingResourceTypes = Arrays.asList(((String)ServiceContext.getContext().getProperty(LIVINGTYPES_JNDI_NAME)).split(","));
|
||||
} catch (Exception e) {livingResourceTypes = new ArrayList<String>();}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Creates a new GCUBEResource's profile manager
|
||||
* Creates a new {@link ProfileResource} and registers the {@link GCUBEResource} in the IS-IC
|
||||
*
|
||||
* @param inputMessage
|
||||
* @return the profile as string
|
||||
* @throws SchemaValidationFault
|
||||
* @param inputMessage defined in the WSDL
|
||||
* @return the registered profile
|
||||
* @throws SchemaValidationException if the string serialization of the resource is not valid
|
||||
* @throws ResourceNotAcceptedFault it the resource is rejected when evaluating the resources' filters
|
||||
* @throws RemoteException
|
||||
* @throws ProfileAlreadyRegisteredFault
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public String createResource(CreateResourceMessage mess) throws SchemaValidationFault, RemoteException,
|
||||
public String createResource(CreateResourceMessage mess)
|
||||
throws SchemaValidationFault, RemoteException,
|
||||
ProfileAlreadyRegisteredFault, ResourceNotAcceptedFault {
|
||||
|
||||
GCUBEResource resource = null;
|
||||
|
@ -106,7 +124,9 @@ public class RegistryFactory extends GCUBEPortType {
|
|||
try {
|
||||
resource = ResourceType.valueOf(mess.getType()).getResourceClass();
|
||||
|
||||
resource.load(new BufferedReader(new InputStreamReader(new ByteArrayInputStream(profile.getBytes("UTF-8")), "UTF-8")));
|
||||
resource.load(new BufferedReader(new InputStreamReader(
|
||||
new ByteArrayInputStream(profile.getBytes("UTF-8")),
|
||||
"UTF-8")));
|
||||
|
||||
// the parse Profile class allows to extract from profiles
|
||||
// information about type/SCOPE/UniqueID
|
||||
|
@ -145,8 +165,7 @@ public class RegistryFactory extends GCUBEPortType {
|
|||
// check if the Resource already exists
|
||||
if (isResourceCreated(resource.getID())) {
|
||||
// update the existing resource
|
||||
logger.warn("A Resource with ID " + resource.getID()
|
||||
+ " is already registered");
|
||||
logger.debug("A Resource with ID " + resource.getID() + " is already registered");
|
||||
UpdateResourceMessage upmess = new UpdateResourceMessage();
|
||||
upmess.setUniqueID(resource.getID());
|
||||
upmess.setXmlProfile(mess.getProfile());
|
||||
|
@ -156,14 +175,18 @@ public class RegistryFactory extends GCUBEPortType {
|
|||
} else {
|
||||
// try to create resource
|
||||
try {
|
||||
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.store();
|
||||
|
||||
// Deleting the WSResource created if != from GHN
|
||||
if (resource.getType().compareTo(GCUBEHostingNode.TYPE) != 0)
|
||||
// Deleting the WSResource created if != from GHN || RI
|
||||
if (! this.isLivingResource(resource))
|
||||
this.scheduleForLazyDeletion(presource);
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
@ -172,21 +195,23 @@ public class RegistryFactory extends GCUBEPortType {
|
|||
throw new RemoteException(msg);
|
||||
}
|
||||
try {
|
||||
updateCounterInfo(resource.getID(), ResourceType.valueOf(mess.getType()), OperationType.create, Calendar.getInstance(), mess.getProfile());
|
||||
updateCounterInfo(resource.getID(), ResourceType.valueOf(
|
||||
mess.getType()), OperationType.create,
|
||||
Calendar.getInstance(), mess.getProfile());
|
||||
|
||||
GCUBEEvent<ServiceContext.RegistryTopic, GCUBEResource> event = new GCUBEEvent<ServiceContext.RegistryTopic, GCUBEResource>();
|
||||
event.setPayload(resource);
|
||||
ServiceContext.getContext().getTopicProducer().notify(
|
||||
ServiceContext.RegistryTopic.CREATE, event);
|
||||
ServiceContext.getContext().getTopicProducer().notify(ServiceContext.RegistryTopic.CREATE, event);
|
||||
} catch (Exception e) {
|
||||
logger.warn("Error updating Counting info for resource with ID " + resource.getID(), e);
|
||||
logger.warn(
|
||||
"Error updating Counting info for resource with ID "
|
||||
+ resource.getID(), e);
|
||||
}
|
||||
}
|
||||
|
||||
StringWriter writer = new StringWriter();
|
||||
try {
|
||||
logger.debug("Persisting the stateful resource for "
|
||||
+ resource.getID());
|
||||
logger.debug("Persisting the stateful resource for " + resource.getID());
|
||||
resource.store(writer);
|
||||
} catch (Exception e) {
|
||||
logger.error("Persistence failed for " + resource.getID(), e);
|
||||
|
@ -204,37 +229,35 @@ public class RegistryFactory extends GCUBEPortType {
|
|||
private void scheduleForLazyDeletion(ProfileResource presource) {
|
||||
|
||||
long timestamp = System.currentTimeMillis() + temporaryResourceLifetimeInMs;
|
||||
GCUBEScope scope = ServiceContext.getContext().getScope().getType() == GCUBEScope.Type.VRE ? ServiceContext
|
||||
.getContext().getScope().getEnclosingScope(): ServiceContext.getContext().getScope();
|
||||
GCUBEScope scope = ServiceContext.getContext().getScope().getType() ==
|
||||
GCUBEScope.Type.VRE ? ServiceContext.getContext().getScope().getEnclosingScope()
|
||||
: ServiceContext.getContext().getScope();
|
||||
|
||||
Pair c = new Pair(timestamp, presource);
|
||||
if (!ServiceContext.threadTable.get(scope.getName()).getStack().contains(c)) {
|
||||
ServiceContext.threadTable.get(scope.getName()).getStack().add(c);
|
||||
logger.trace("Adding resource to EliminatePoolingThread "+ presource.getGCubeResource().getID());
|
||||
} else { //add more life to the resource by further delaying its deletion
|
||||
} else { // add more life to the resource by further delaying its
|
||||
// deletion
|
||||
int index = ServiceContext.threadTable.get(scope.getName()).getStack().indexOf(c);
|
||||
ServiceContext.threadTable.get(scope.getName()).getStack().get(index).lifetime = timestamp + temporaryResourceLifetimeInMs;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates Resource Profiles (in case of an update of an ID not present it
|
||||
* invokes calls the Create resource operation)
|
||||
* Updates a {@link GCUBEResource}
|
||||
*
|
||||
* @param mess
|
||||
* Complex Object that contains a String representing the XML
|
||||
* profile to update and the diligentID
|
||||
* @param mess Complex Object that contains a String representing the XML profile to update and the diligentID
|
||||
* @return UpdateResourceResponse
|
||||
* @throws RemoteException
|
||||
* Exception
|
||||
* @throws SchemaValidationException
|
||||
* Exception
|
||||
* @throws RemoteException Exception
|
||||
* @throws SchemaValidationException if the string serialization of the resource is not valid
|
||||
* @throws ResourceNotAcceptedFault it the resource is rejected when evaluating the resources' filters
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public UpdateResourceResponse updateResource(UpdateResourceMessage mess)
|
||||
throws RemoteException, SchemaValidationFault, ResourceNotAcceptedFault, GCUBEFault {
|
||||
throws RemoteException, SchemaValidationFault,
|
||||
ResourceNotAcceptedFault, GCUBEFault {
|
||||
|
||||
logger.info("UpdateResource operation invoked");
|
||||
String ID = mess.getUniqueID();
|
||||
|
@ -269,14 +292,15 @@ public class RegistryFactory extends GCUBEPortType {
|
|||
}
|
||||
logger.trace("Resource " + resource.getID() + " accepted ");
|
||||
} catch (InvalidFilterException e) {
|
||||
logger.warn("Invalid filter selected, the resource " + resource.getID() + " CANNOT be filtered ");
|
||||
logger.warn("Invalid filter selected, the resource "
|
||||
+ resource.getID() + " CANNOT be filtered ");
|
||||
}
|
||||
|
||||
ProfileResource presource = getProfileResource(ID);
|
||||
presource.updateResource(resource);
|
||||
|
||||
// Deleting the WSResource created
|
||||
if (resource.getType().compareTo(GCUBEHostingNode.TYPE) != 0)
|
||||
// Deleting the WSResource created if != from GHN || RI
|
||||
if (! this.isLivingResource(resource))
|
||||
this.scheduleForLazyDeletion(presource);
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -285,7 +309,8 @@ public class RegistryFactory extends GCUBEPortType {
|
|||
}
|
||||
|
||||
try {
|
||||
this.updateCounterInfo(ID, ResourceType.valueOf(mess.getType()), OperationType.update, Calendar.getInstance(), xmlProfile);
|
||||
this.updateCounterInfo(ID, ResourceType.valueOf(mess.getType()),
|
||||
OperationType.update, Calendar.getInstance(), xmlProfile);
|
||||
GCUBEEvent<ServiceContext.RegistryTopic, GCUBEResource> event = new GCUBEEvent<ServiceContext.RegistryTopic, GCUBEResource>();
|
||||
event.setPayload(resource);
|
||||
ServiceContext.getContext().getTopicProducer().notify(ServiceContext.RegistryTopic.UPDATE, event);
|
||||
|
@ -304,24 +329,31 @@ public class RegistryFactory extends GCUBEPortType {
|
|||
* @throws RemoteException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public RemoveResourceResponse removeResource(RemoveResourceMessage inputMessage) throws RemoteException, GCUBEFault {
|
||||
//logSecurityInfo("removeResource");
|
||||
public RemoveResourceResponse removeResource(
|
||||
RemoveResourceMessage inputMessage) throws RemoteException, GCUBEFault {
|
||||
|
||||
String ID = inputMessage.getUniqueID();
|
||||
String type = inputMessage.getType();
|
||||
logger.info("RemoveResource operation invoked on resource ID=" + ID + ", type=" + type);
|
||||
logger.info("RemoveResource operation invoked on resource ID=" + ID
|
||||
+ ", type=" + type);
|
||||
if (ID == null || ID.compareTo("") == 0) {
|
||||
logger.warn("Resource ID is missing, cannot manage the resource");
|
||||
throw new RemoteException("Resource ID is missing, cannot manage the resource");
|
||||
throw new RemoteException(
|
||||
"Resource ID is missing, cannot manage the resource");
|
||||
}
|
||||
|
||||
try {
|
||||
logger.debug("Trying to remove the resource from the IS-IC");
|
||||
new ProfileManager().removeFromISIC(ID, type, ServiceContext.getContext().getScope(), ServiceContext.getContext());
|
||||
new ProfileManager().removeFromISIC(ID, type, ServiceContext
|
||||
.getContext().getScope(), ServiceContext.getContext());
|
||||
logger.info("Resource removed from the IS-IC");
|
||||
} catch (Exception e) {
|
||||
logger.error("Unable to remove the resource", e);
|
||||
throw ServiceContext.getContext().getDefaultException("", e).toFault( "Unable to remove the resource: the remote IS-IC returned an error");
|
||||
throw ServiceContext
|
||||
.getContext()
|
||||
.getDefaultException("", e)
|
||||
.toFault(
|
||||
"Unable to remove the resource: the remote IS-IC returned an error");
|
||||
}
|
||||
// if the resource is a GHN, remove also the related RIs
|
||||
try {
|
||||
|
@ -332,14 +364,16 @@ public class RegistryFactory extends GCUBEPortType {
|
|||
logger.debug("Related RIs removed");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("Error while removing RI profiles related to the GHN", e);
|
||||
logger.error("Error while removing RI profiles related to the GHN",
|
||||
e);
|
||||
}
|
||||
|
||||
if (this.isResourceCreated(ID)) {
|
||||
// destroy the resource
|
||||
try {
|
||||
logger.debug("Destroying the local stateful Resoruce");
|
||||
ProfileContext.getContext().getWSHome().remove(ProfileContext.getContext().makeKey(ID));
|
||||
ProfileContext.getContext().getWSHome().remove(
|
||||
ProfileContext.getContext().makeKey(ID));
|
||||
logger.info(" Resource Destroyed");
|
||||
} catch (Exception e) {
|
||||
logger.error("Error removing resource for ID ", e);
|
||||
|
@ -347,13 +381,18 @@ public class RegistryFactory extends GCUBEPortType {
|
|||
}
|
||||
try {
|
||||
GCUBEEvent<ServiceContext.RegistryTopic, GCUBEResource> event = new GCUBEEvent<ServiceContext.RegistryTopic, GCUBEResource>();
|
||||
GCUBEResource resource = ResourceType.valueOf(type).getResourceClass();
|
||||
GCUBEResource resource = ResourceType.valueOf(type)
|
||||
.getResourceClass();
|
||||
resource.setID(ID);
|
||||
event.setPayload(resource);
|
||||
ServiceContext.getContext().getTopicProducer().notify(ServiceContext.RegistryTopic.REMOVE, event);
|
||||
updateCounterInfo(ID, ResourceType.valueOf(type),OperationType.destroy, Calendar.getInstance(),null);
|
||||
ServiceContext.getContext().getTopicProducer().notify(
|
||||
ServiceContext.RegistryTopic.REMOVE, event);
|
||||
updateCounterInfo(ID, ResourceType.valueOf(type),
|
||||
OperationType.destroy, Calendar.getInstance(), null);
|
||||
} catch (Exception e) {
|
||||
logger.warn("Error updating counting info for resource with ID " + ID, e);
|
||||
logger.warn(
|
||||
"Error updating counting info for resource with ID "
|
||||
+ ID, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -361,30 +400,28 @@ public class RegistryFactory extends GCUBEPortType {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the Resource has been created
|
||||
* Gets the profile resource
|
||||
*
|
||||
* @param id
|
||||
* the Resource ID
|
||||
* @return the resource ( null if the resource has not been created yet
|
||||
* @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");
|
||||
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
|
||||
* @return
|
||||
* @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)
|
||||
|
@ -396,22 +433,15 @@ public class RegistryFactory extends GCUBEPortType {
|
|||
/**
|
||||
* Updates the RegistryFactoryResource RPs for notification
|
||||
*
|
||||
*
|
||||
* @param ID
|
||||
* resource ID
|
||||
* @param type
|
||||
* the resource type
|
||||
* @param operationType
|
||||
* the type of Operation performed on the Profile
|
||||
* @param updateTime
|
||||
* The last operation Time
|
||||
* @throws Exception
|
||||
* Exception
|
||||
* @param ID resource ID
|
||||
* @param type the resource type
|
||||
* @param operationType the type of Operation performed on the Profile
|
||||
* @param updateTime the last operation Time
|
||||
* @throws Exception if the update fails
|
||||
*/
|
||||
|
||||
private synchronized void updateCounterInfo(String ID,
|
||||
ResourceType resType, OperationType opType, Calendar updateTime, String profile)
|
||||
throws Exception {
|
||||
ResourceType resType, OperationType opType, Calendar updateTime,
|
||||
String profile) throws Exception {
|
||||
|
||||
RegistryProperty property = new RegistryProperty();
|
||||
property.setUniqueID(ID);
|
||||
|
@ -431,10 +461,10 @@ public class RegistryFactory extends GCUBEPortType {
|
|||
}
|
||||
|
||||
/**
|
||||
* return the resource
|
||||
* Gets the factory stateful resource
|
||||
*
|
||||
* @return NotifierResource resource
|
||||
* @throws RemoteException
|
||||
* @return the resource
|
||||
* @throws RemoteException if the stateful resource of the factory cannot be found in the home
|
||||
*
|
||||
*/
|
||||
private RegistryFactoryResource getResource() throws RemoteException {
|
||||
|
@ -450,6 +480,18 @@ public class RegistryFactory extends GCUBEPortType {
|
|||
return factoryResource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decides whether the given resource is a living resource.
|
||||
*
|
||||
* Living resources are those resources that are not automatically destroyed because they are updated regularly.
|
||||
*
|
||||
* @param resource the resource to check
|
||||
* @return <tt>true</tt> if the given resource is a living resource, <tt>false</tt> otherwise
|
||||
*/
|
||||
private boolean isLivingResource(GCUBEResource resource) {
|
||||
return (livingResourceTypes.contains(resource.getType()))? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -459,3 +501,4 @@ public class RegistryFactory extends GCUBEPortType {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue