This closes #1384
This commit is contained in:
commit
74349fd178
|
@ -44,6 +44,7 @@ public class FileStoreMonitor extends ActiveMQScheduledComponent {
|
|||
private final Set<Callback> callbackList = new HashSet<>();
|
||||
private final Set<FileStore> stores = new HashSet<>();
|
||||
private double maxUsage;
|
||||
private final Object monitorLock = new Object();
|
||||
|
||||
public FileStoreMonitor(ScheduledExecutorService scheduledExecutorService,
|
||||
Executor executor,
|
||||
|
@ -54,30 +55,37 @@ public class FileStoreMonitor extends ActiveMQScheduledComponent {
|
|||
this.maxUsage = maxUsage;
|
||||
}
|
||||
|
||||
public synchronized FileStoreMonitor addCallback(Callback callback) {
|
||||
public FileStoreMonitor addCallback(Callback callback) {
|
||||
synchronized (monitorLock) {
|
||||
callbackList.add(callback);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized FileStoreMonitor addStore(File file) throws IOException {
|
||||
public FileStoreMonitor addStore(File file) throws IOException {
|
||||
synchronized (monitorLock) {
|
||||
// JDBC storage may return this as null, and we may need to ignore it
|
||||
if (file != null && file.exists()) {
|
||||
addStore(Files.getFileStore(file.toPath()));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized FileStoreMonitor addStore(FileStore store) {
|
||||
public FileStoreMonitor addStore(FileStore store) {
|
||||
synchronized (monitorLock) {
|
||||
stores.add(store);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
tick();
|
||||
}
|
||||
|
||||
public synchronized void tick() {
|
||||
public void tick() {
|
||||
synchronized (monitorLock) {
|
||||
boolean over = false;
|
||||
|
||||
FileStore lastStore = null;
|
||||
|
@ -106,6 +114,7 @@ public class FileStoreMonitor extends ActiveMQScheduledComponent {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double getMaxUsage() {
|
||||
return maxUsage;
|
||||
|
|
Loading…
Reference in New Issue