Added CrawlCache expired management feature.

This commit is contained in:
Christian P. MOMON 2024-08-12 05:46:41 +02:00
parent cfec6aab7c
commit d024d02409
7 changed files with 51 additions and 1 deletions

View file

@ -36,5 +36,10 @@
<attribute name="owner.project.facets" value="jst.utility"/> <attribute name="owner.project.facets" value="jst.utility"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="src" path=".apt_generated">
<attributes>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

1
.gitignore vendored
View file

@ -2,3 +2,4 @@
/build /build
/dist /dist
*~ *~
/.apt_generated/

View file

@ -0,0 +1,5 @@
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=true
org.eclipse.jdt.apt.genSrcDir=.apt_generated
org.eclipse.jdt.apt.genTestSrcDir=.apt_generated_tests
org.eclipse.jdt.apt.reconcileEnabled=true

View file

@ -21,6 +21,7 @@ org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.processAnnotations=enabled
org.eclipse.jdt.core.compiler.release=enabled org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=17 org.eclipse.jdt.core.compiler.source=17
org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false

View file

@ -152,6 +152,7 @@ org.eclipse.jdt.ui.exception.name=exception
org.eclipse.jdt.ui.gettersetter.use.is=true org.eclipse.jdt.ui.gettersetter.use.is=true
org.eclipse.jdt.ui.keywordthis=false org.eclipse.jdt.ui.keywordthis=false
org.eclipse.jdt.ui.overrideannotation=true org.eclipse.jdt.ui.overrideannotation=true
org.eclipse.jdt.ui.text.custom_code_templates=
sp_cleanup.add_all=false sp_cleanup.add_all=false
sp_cleanup.add_default_serial_version_id=true sp_cleanup.add_default_serial_version_id=true
sp_cleanup.add_generated_serial_version_id=false sp_cleanup.add_generated_serial_version_id=false

View file

@ -1,6 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> <?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="SikevaDB">
<wb-module deploy-name="StatooInfos">
<wb-resource deploy-path="/" source-path="/src"/> <wb-resource deploy-path="/" source-path="/src"/>
<wb-resource deploy-path="/" source-path="/test"/> <wb-resource deploy-path="/" source-path="/test"/>
<wb-resource deploy-path="/" source-path="/.apt_generated"/>
</wb-module> </wb-module>
</project-modules> </project-modules>

View file

@ -21,6 +21,8 @@ package fr.devinsy.statoolinfos.core;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import fr.devinsy.statoolinfos.crawl.CrawlCache; import fr.devinsy.statoolinfos.crawl.CrawlCache;
import fr.devinsy.statoolinfos.uptime.UptimeJournal; import fr.devinsy.statoolinfos.uptime.UptimeJournal;
@ -32,6 +34,7 @@ public class StatoolInfosContext
{ {
private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(StatoolInfosContext.class); private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(StatoolInfosContext.class);
private LocalDateTime initDateTime;
private Configuration configuration; private Configuration configuration;
private Federation federation; private Federation federation;
private Categories categories; private Categories categories;
@ -81,6 +84,7 @@ public class StatoolInfosContext
this.categories = Factory.loadCategories(categoriesURL, this.federation); this.categories = Factory.loadCategories(categoriesURL, this.federation);
} }
this.uptimeJournal = this.cache.restoreUptimeJournal(); this.uptimeJournal = this.cache.restoreUptimeJournal();
this.initDateTime = LocalDateTime.now();
System.out.println("Loaded configuration context in " + (System.currentTimeMillis() - startTime) + " ms."); System.out.println("Loaded configuration context in " + (System.currentTimeMillis() - startTime) + " ms.");
} }
else else
@ -158,4 +162,31 @@ public class StatoolInfosContext
{ {
return this.uptimeJournal; return this.uptimeJournal;
} }
/**
* Checks if is expired.
*
* @return true, if is expired
*/
public boolean isExpired()
{
boolean result;
getCache();
long cacheTime = this.getCache().getDirectory().lastModified();
LocalDateTime cacheDateTime = LocalDateTime.ofEpochSecond(cacheTime / 1000, 0, OffsetDateTime.now().getOffset());
if (cacheDateTime.isAfter(this.initDateTime))
{
result = true;
}
else
{
result = false;
}
//
return result;
}
} }