This commit is contained in:
@@ -124,7 +124,11 @@ public class TransportFactory {
|
||||
return t;
|
||||
});
|
||||
this.scheduler.scheduleAtFixedRate(() -> {
|
||||
checks();
|
||||
try {
|
||||
checks();
|
||||
} catch (Throwable t) {
|
||||
logger.log(Level.SEVERE, "TransportFactory schedule(interval=" + checkinterval + "s) check error", t);
|
||||
}
|
||||
}, checkinterval, checkinterval, TimeUnit.SECONDS);
|
||||
|
||||
if (this.pinginterval > 0) {
|
||||
|
||||
@@ -407,8 +407,13 @@ public class HttpServer extends Server<String, HttpContext, HttpRequest, HttpRes
|
||||
final DateFormat gmtDateFormat = new SimpleDateFormat("EEE, d MMM y HH:mm:ss z", Locale.ENGLISH);
|
||||
gmtDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
currDateBytes = ("Date: " + gmtDateFormat.format(new Date()) + "\r\n").getBytes();
|
||||
final int dp = datePeriod;
|
||||
this.dateScheduler.scheduleAtFixedRate(() -> {
|
||||
currDateBytes = ("Date: " + gmtDateFormat.format(new Date()) + "\r\n").getBytes();
|
||||
try {
|
||||
currDateBytes = ("Date: " + gmtDateFormat.format(new Date()) + "\r\n").getBytes();
|
||||
} catch (Throwable t) {
|
||||
logger.log(Level.SEVERE, "HttpServer schedule(interval=" + dp + "ms) date-format error", t);
|
||||
}
|
||||
}, 1000 - System.currentTimeMillis() % 1000, datePeriod, TimeUnit.MILLISECONDS);
|
||||
dateSupplier = () -> currDateBytes;
|
||||
}
|
||||
|
||||
@@ -107,8 +107,12 @@ public class WebSocketEngine {
|
||||
long delay = (liveinterval - System.currentTimeMillis() / 1000 % liveinterval) + index * 5;
|
||||
final int intervalms = liveinterval * 1000;
|
||||
scheduler.scheduleWithFixedDelay(() -> {
|
||||
long now = System.currentTimeMillis();
|
||||
getLocalWebSockets().stream().filter(x -> (now - x.getLastReadTime()) > intervalms).forEach(x -> x.sendPing());
|
||||
try {
|
||||
long now = System.currentTimeMillis();
|
||||
getLocalWebSockets().stream().filter(x -> (now - x.getLastReadTime()) > intervalms).forEach(x -> x.sendPing());
|
||||
} catch (Throwable t) {
|
||||
logger.log(Level.SEVERE, "WebSocketEngine schedule(interval=" + liveinterval + "s) ping error", t);
|
||||
}
|
||||
}, delay, liveinterval, TimeUnit.SECONDS);
|
||||
if (logger.isLoggable(Level.FINEST)) logger.finest(this.getClass().getSimpleName() + "(" + engineid + ")" + " start keeplive(wsmaxconns:" + wsmaxconns + ", delay:" + delay + "s, interval:" + liveinterval + "s) scheduler executor");
|
||||
}
|
||||
|
||||
@@ -123,16 +123,20 @@ public class CacheMemorySource<V extends Object> extends AbstractService impleme
|
||||
});
|
||||
final List<String> keys = new ArrayList<>();
|
||||
scheduler.scheduleWithFixedDelay(() -> {
|
||||
keys.clear();
|
||||
int now = (int) (System.currentTimeMillis() / 1000);
|
||||
container.forEach((k, x) -> {
|
||||
if (x.expireSeconds > 0 && (now > (x.lastAccessed + x.expireSeconds))) {
|
||||
keys.add(x.key);
|
||||
try {
|
||||
keys.clear();
|
||||
int now = (int) (System.currentTimeMillis() / 1000);
|
||||
container.forEach((k, x) -> {
|
||||
if (x.expireSeconds > 0 && (now > (x.lastAccessed + x.expireSeconds))) {
|
||||
keys.add(x.key);
|
||||
}
|
||||
});
|
||||
for (String key : keys) {
|
||||
CacheEntry entry = container.remove(key);
|
||||
if (expireHandler != null && entry != null) expireHandler.accept(entry);
|
||||
}
|
||||
});
|
||||
for (String key : keys) {
|
||||
CacheEntry entry = container.remove(key);
|
||||
if (expireHandler != null && entry != null) expireHandler.accept(entry);
|
||||
} catch (Throwable t) {
|
||||
logger.log(Level.SEVERE, "CacheMemorySource schedule(interval=" + 10 + "s) error", t);
|
||||
}
|
||||
}, 10, 10, TimeUnit.SECONDS);
|
||||
if (logger.isLoggable(Level.FINEST)) logger.finest(self.getClass().getSimpleName() + ":" + self.resourceName() + " start schedule expire executor");
|
||||
|
||||
@@ -118,15 +118,19 @@ public final class EntityCache<T> {
|
||||
return t;
|
||||
});
|
||||
this.scheduler.scheduleAtFixedRate(() -> {
|
||||
ConcurrentHashMap newmap2 = new ConcurrentHashMap();
|
||||
List<T> all2 = info.fullloader.apply(info.source, type);
|
||||
if (all2 != null) {
|
||||
all2.stream().filter(x -> x != null).forEach(x -> {
|
||||
newmap2.put(this.primary.get(x), x);
|
||||
});
|
||||
try {
|
||||
ConcurrentHashMap newmap2 = new ConcurrentHashMap();
|
||||
List<T> all2 = info.fullloader.apply(info.source, type);
|
||||
if (all2 != null) {
|
||||
all2.stream().filter(x -> x != null).forEach(x -> {
|
||||
newmap2.put(this.primary.get(x), x);
|
||||
});
|
||||
}
|
||||
this.list = all2 == null ? new ConcurrentLinkedQueue() : new ConcurrentLinkedQueue(all2);
|
||||
this.map = newmap2;
|
||||
} catch (Throwable t) {
|
||||
logger.log(Level.SEVERE, type + " schedule(interval=" + interval + "s) Cacheable error", t);
|
||||
}
|
||||
this.list = all2 == null ? new ConcurrentLinkedQueue() : new ConcurrentLinkedQueue(all2);
|
||||
this.map = newmap2;
|
||||
}, interval - System.currentTimeMillis() / 1000 % interval, interval, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user