1
|
|
|
package io.mcarle.sciurus; |
2
|
|
|
|
3
|
|
|
import io.mcarle.sciurus.cache.CacheRegister; |
4
|
|
|
import io.mcarle.sciurus.cache.CacheSupplier; |
5
|
|
|
import io.mcarle.sciurus.cache.CustomCache; |
6
|
|
|
import io.mcarle.sciurus.monitor.CustomMonitor; |
7
|
|
|
import io.mcarle.sciurus.monitor.MonitorRegister; |
8
|
|
|
import org.slf4j.Logger; |
9
|
|
|
import org.slf4j.LoggerFactory; |
10
|
|
|
|
11
|
1 |
|
public final class Sciurus { |
12
|
|
|
|
13
|
1 |
|
private final static Logger LOG = LoggerFactory.getLogger(Sciurus.class); |
14
|
|
|
public final static String CACHE_GLOBAL = "CACHE_GLOBAL"; |
15
|
|
|
public final static String CACHE_MAP = "CACHE_MAP"; |
16
|
|
|
|
17
|
1 |
|
private static boolean MONITOR_STARTED = false; |
18
|
1 |
|
private static boolean CACHE_STARTED = false; |
19
|
|
|
|
20
|
|
|
public static boolean registerMonitor(CustomMonitor monitor) { |
21
|
1 |
|
LOG.trace("Register monitor {}", monitor); |
22
|
1 |
|
return MonitorRegister.INSTANCE.register(monitor); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public static boolean deregisterMonitor(CustomMonitor monitor) { |
26
|
1 |
|
LOG.trace("Deregister monitor {}", monitor); |
27
|
1 |
|
return MonitorRegister.INSTANCE.deregister(monitor); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public static void registerCache(String cacheName, CustomCache customCache) { |
31
|
1 |
|
LOG.trace("Register cache {}", cacheName); |
32
|
1 |
|
CacheRegister.INSTANCE.register(cacheName, customCache); |
33
|
1 |
|
} |
34
|
|
|
|
35
|
|
|
public static void registerCache(String cacheName, CacheSupplier customCacheSupplier) { |
36
|
1 |
|
LOG.trace("Register cache {}", cacheName); |
37
|
1 |
|
CacheRegister.INSTANCE.register(cacheName, customCacheSupplier); |
38
|
1 |
|
} |
39
|
|
|
|
40
|
|
|
public static boolean deregisterCache(String cacheName) { |
41
|
1 |
|
LOG.trace("Deregister cache {}", cacheName); |
42
|
1 |
|
return CacheRegister.INSTANCE.deregister(cacheName); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/* |
46
|
|
|
* start, stop, isStarted methods: |
47
|
|
|
*/ |
48
|
|
|
|
49
|
|
|
public static void startMonitor() { |
50
|
1 |
|
MONITOR_STARTED = true; |
51
|
1 |
|
LOG.debug("Monitor started"); |
52
|
1 |
|
} |
53
|
|
|
|
54
|
|
|
public static void stopMonitor() { |
55
|
1 |
|
MONITOR_STARTED = false; |
56
|
1 |
|
LOG.debug("Monitor stopped"); |
57
|
1 |
|
} |
58
|
|
|
|
59
|
|
|
public static void startCache() { |
60
|
1 |
|
CACHE_STARTED = true; |
61
|
1 |
|
LOG.debug("Cache started"); |
62
|
1 |
|
} |
63
|
|
|
|
64
|
|
|
public static void stopCache() { |
65
|
1 |
|
CACHE_STARTED = false; |
66
|
1 |
|
LOG.debug("Cache stopped"); |
67
|
1 |
|
} |
68
|
|
|
|
69
|
|
|
|
70
|
|
|
public static boolean isMonitorStarted() { |
71
|
1 |
|
return MONITOR_STARTED; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public static boolean isCacheStarted() { |
75
|
1 |
|
return CACHE_STARTED; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
} |
79
|
|
|
|