csip.Sweeper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of csip-core Show documentation
Show all versions of csip-core Show documentation
The Cloud Services Integration Platform is a SoA implementation to offer a Model-as-a-Service framework, Application Programming Interface, deployment infrastructure, and service implementations for environmental modeling.
/*
* $Id: Sweeper.java 27bed8415b8b 2019-01-31 od $
*
* This file is part of the Cloud Services Integration Platform (CSIP),
* a Model-as-a-Service framework, API and application suite.
*
* 2012-2019, Olaf David and others, OMSLab, Colorado State University.
*
* OMSLab licenses this file to you under the MIT license.
* See the LICENSE file in the project root for more information.
*/
package csip;
import java.io.File;
import java.util.ArrayList;
import java.util.TimerTask;
import org.apache.commons.io.FileUtils;
/**
*
* @author od
*/
class Sweeper extends TimerTask {
File resultsDir;
String suid;
Sweeper(File resultsDir, String suid) {
this.resultsDir = resultsDir;
this.suid = suid;
}
@Override
public void run() {
try {
// remove all file locks for the workspace
for (File key : new ArrayList<>(Config.wsFileLocks.keySet())) {
if (key.toString().startsWith(resultsDir.toString())) {
Config.wsFileLocks.remove(key);
}
}
Config.getSessionStore().removeSession(suid);
} catch (Exception E) {
Config.LOG.warning("Error removing session: " + suid + " " + E.getMessage());
}
if (resultsDir != null && resultsDir.exists()) {
FileUtils.deleteQuietly(resultsDir);
}
Config.getPublisher().publish("Expired", suid);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy