Removing sleep() from the sweeper (use an executor, instead)
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Collector@40763 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
5e0baa7201
commit
30d08687ea
|
@ -18,9 +18,9 @@ import org.gcube.informationsystem.collector.impl.resources.GCUBEInstanceStateRe
|
|||
import org.gcube.informationsystem.collector.impl.resources.GCUBEXMLResource;
|
||||
|
||||
/**
|
||||
* This class provides some cleanup procedures to use to maintain a consistent
|
||||
* content in the XML storage. One of them is a thread, activated at RI startup
|
||||
* time, that periodically drops the out to date resources from the storage
|
||||
* This class provides some cleanup procedures to use to maintain a consistent content in the XML
|
||||
* storage. One of them is a thread, activated at RI startup time, that periodically drops the out
|
||||
* to date resources from the storage
|
||||
*
|
||||
* @author Manuele Simi (ISTI-CNR)
|
||||
*
|
||||
|
@ -38,9 +38,12 @@ public class Sweeper implements Runnable {
|
|||
/**
|
||||
* Initializes a new Sweeper
|
||||
*
|
||||
* @param delay the sweeper delay
|
||||
* @param resourceExpirationTime the time after that a resource is classified as exipired
|
||||
* @throws Exception if the eXist connection fails
|
||||
* @param delay
|
||||
* the sweeper delay
|
||||
* @param resourceExpirationTime
|
||||
* the time after that a resource is classified as exipired
|
||||
* @throws Exception
|
||||
* if the eXist connection fails
|
||||
*/
|
||||
public Sweeper(long delay, long resourceExpirationTime) throws Exception {
|
||||
Sweeper.DELAY = delay;
|
||||
|
@ -53,19 +56,12 @@ public class Sweeper implements Runnable {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
public void run() {
|
||||
if (Sweeper.DELAY == -1) return;
|
||||
try {
|
||||
while (!Thread.interrupted()) {
|
||||
Thread.sleep(Sweeper.DELAY);
|
||||
if (Sweeper.DELAY == -1)
|
||||
return;
|
||||
logger.info("Starting IC sweeper...");
|
||||
this.cleanDeletedResourcesList();
|
||||
this.cleanExpiredResources();
|
||||
}
|
||||
} catch (InterruptedException ie) {
|
||||
logger.error("Unable to sleep (yawn)", ie);
|
||||
// thread was interrupted
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes from the backend storage the expired resources
|
||||
|
@ -102,9 +98,9 @@ public class Sweeper implements Runnable {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deletes the Properties collection from the storage
|
||||
*
|
||||
* @throws XMLStorageNotAvailableException
|
||||
*
|
||||
*/
|
||||
|
@ -114,8 +110,7 @@ public class Sweeper implements Runnable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Deletes the expired resources from the list of deleted resources as
|
||||
* notified by the AF
|
||||
* Deletes the expired resources from the list of deleted resources as notified by the AF
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
Loading…
Reference in New Issue