- /**
- * Clean will examine resources, and remove those that have expired.
- *
- * If "highs" have been exceeded, then we'll expire 10% more the next time. This will adjust after each run
- * without checking contents more than once, making a good average "high" in the minimum speed.
- *
- * @author Jonathan
- *
- */
- private static final class Clean extends TimerTask {
- private final Access access;
- private long hourly;
-
- public Clean(Access access) {
- this.access = access;
- hourly=0;
- }
-
- private static class Metrics {
- public int mexists = 0, dexists=0;
- public int mremoved = 0, dremoved=0;
- }
-
- public void run() {
- final long now = System.currentTimeMillis();
- final long dayFromNow = now + ONE_DAY;
- final Metrics metrics = new Metrics();
- for(final Persist<?,?> persist : allPersists) {
- // Clear memory
- if(access.willLog(Level.DEBUG)) {
- access.log(Level.DEBUG, "Persist: Cleaning memory cache for",persist.tokenPath.toAbsolutePath());
- }
- for(Entry<String, ?> es : persist.tmap.entrySet()) {
- ++metrics.mexists;
- Persistable<?> p = (Persistable<?>)es.getValue();
- if(p.checkSyncTime()) {
- if(p.count()==0) {
- ++metrics.mremoved;
- persist.tmap.remove(es.getKey());
- access.printf(Level.DEBUG, "Persist: removed cached item %s from memory\n", es.getKey());
- } else {
- p.clearCount();
- }
- } else if(Files.exists(p.path())) {
-
- }
- }
- // Clear disk
- try {
- final StringBuilder sb = new StringBuilder();
- Files.walkFileTree(persist.tokenPath, new FileVisitor<Path>() {
- @Override
- public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
- sb.setLength(0);
- sb.append("Persist: Cleaning files from ");
- sb.append(dir.toAbsolutePath());
- return FileVisitResult.CONTINUE;
- }
+ /**
+ * Clean will examine resources, and remove those that have expired.
+ *
+ * If "highs" have been exceeded, then we'll expire 10% more the next time. This will adjust after each run
+ * without checking contents more than once, making a good average "high" in the minimum speed.
+ *
+ * @author Jonathan
+ *
+ */
+ private static final class Clean extends TimerTask {
+ private final Access access;
+ private long hourly;
+
+ public Clean(Access access) {
+ this.access = access;
+ hourly=0;
+ }
+
+ private static class Metrics {
+ public int mexists = 0, dexists=0;
+ public int mremoved = 0, dremoved=0;
+ }
+
+ public void run() {
+ final long now = System.currentTimeMillis();
+ final long dayFromNow = now + ONE_DAY;
+ final Metrics metrics = new Metrics();
+ for(final Persist<?,?> persist : allPersists) {
+ // Clear memory
+ if(access.willLog(Level.DEBUG)) {
+ access.log(Level.DEBUG, "Persist: Cleaning memory cache for",persist.tokenPath.toAbsolutePath());
+ }
+ for(Entry<String, ?> es : persist.tmap.entrySet()) {
+ ++metrics.mexists;
+ Persistable<?> p = (Persistable<?>)es.getValue();
+ if(p.checkSyncTime()) {
+ if(p.count()==0) {
+ ++metrics.mremoved;
+ persist.tmap.remove(es.getKey());
+ access.printf(Level.DEBUG, "Persist: removed cached item %s from memory\n", es.getKey());
+ } else {
+ p.clearCount();
+ }
+ } else if(Files.exists(p.path())) {
+
+ }
+ }
+ // Clear disk
+ try {
+ final StringBuilder sb = new StringBuilder();
+ Files.walkFileTree(persist.tokenPath, new FileVisitor<Path>() {
+ @Override
+ public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
+ sb.setLength(0);
+ sb.append("Persist: Cleaning files from ");
+ sb.append(dir.toAbsolutePath());
+ return FileVisitResult.CONTINUE;
+ }