XQuery locking issue fixed

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Collector@15579 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Manuele Simi 2009-09-27 20:08:18 +00:00
parent 2f81819f91
commit aca4200071
3 changed files with 50 additions and 41 deletions

View File

@ -93,7 +93,7 @@
<Shareable level="VO"/> <Shareable level="VO"/>
<Type>application</Type> <Type>application</Type>
<Files> <Files>
<File>org.gcube.informationsystem.collector.testsuite.jar</File> <File>lib/org.gcube.informationsystem.collector.testsuite.jar</File>
</Files> </Files>
</Software> </Software>
</Packages> </Packages>

View File

@ -35,8 +35,10 @@ public class QueryManager extends XMLStorageManager {
int attempts = 0; int attempts = 0;
ResourceSet result = null; ResourceSet result = null;
Collection currentCollection = null; Collection currentCollection = null;
State.getDataManager().lock();
try {
currentCollection = this.loadAllCollections(); currentCollection = this.loadAllCollections();
this.lock();
while ((retry) && (attempts < MAXQUERYATTEMPTS)) { while ((retry) && (attempts < MAXQUERYATTEMPTS)) {
try { try {
// execute query and get results in ResourceSet // execute query and get results in ResourceSet
@ -70,9 +72,11 @@ public class QueryManager extends XMLStorageManager {
} }
} }
//operationsCounter++;
this.resetCollection(currentCollection); this.resetCollection(currentCollection);
this.unlock(); } catch (Exception e) {
logger.error("Failed to execute the XQuery", e);
} finally {State.getDataManager().unlock(); }
//operationsCounter++;
//this.checkConnection(); //this.checkConnection();
return result; return result;
} }

View File

@ -314,8 +314,12 @@ public class XMLStorageManager {
*/ */
public void storeResource(PersistentResource resource) throws XMLStorageNotAvailableException, MalformedResourceException { public void storeResource(PersistentResource resource) throws XMLStorageNotAvailableException, MalformedResourceException {
if (status != STATUS.INITIALISED) this.lock();
if (status != STATUS.INITIALISED) {
this.unlock();
throw new XMLStorageNotAvailableException("XMLStorage not initialized"); throw new XMLStorageNotAvailableException("XMLStorage not initialized");
}
Collection currentCollection = null; Collection currentCollection = null;
if (resource.getType() == RESOURCETYPE.Profile) { if (resource.getType() == RESOURCETYPE.Profile) {
// the entry contains a gCube resource profile // the entry contains a gCube resource profile
@ -327,9 +331,10 @@ public class XMLStorageManager {
if (currentCollection == null) { if (currentCollection == null) {
logger.error("Unable to open the Collection"); logger.error("Unable to open the Collection");
this.unlock();
throw new XMLStorageNotAvailableException("Unable to open the Collection"); throw new XMLStorageNotAvailableException("Unable to open the Collection");
} }
this.lock();
try { try {
XMLResource document = (XMLResource) currentCollection.createResource(resource.getID(), "XMLResource"); XMLResource document = (XMLResource) currentCollection.createResource(resource.getID(), "XMLResource");
document.setContent(resource.toString()); document.setContent(resource.toString());