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