com.custardsource.parfait.CompositeMonitoringView Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of parfait-core Show documentation
Show all versions of parfait-core Show documentation
Java performance monitoring framework, including PCP bridge
The newest version!
package com.custardsource.parfait;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterators;
import java.util.Collection;
import java.util.List;
import static com.google.common.collect.ImmutableList.copyOf;
public class CompositeMonitoringView implements MonitoringView{
private final List monitoringViews;
public CompositeMonitoringView(MonitoringView... monitoringViews) {
this.monitoringViews = copyOf(monitoringViews);
}
@Override
public void startMonitoring(Collection> monitorables) {
for (MonitoringView monitoringView : monitoringViews) {
monitoringView.startMonitoring(monitorables);
}
}
@Override
public void stopMonitoring(Collection> monitorables) {
for (MonitoringView monitoringView : monitoringViews) {
monitoringView.stopMonitoring(monitorables);
}
}
@Override
/**
* For a Composite view, isRunning() is true if any of the underlying views are still running
*/
public boolean isRunning() {
return Iterators.any(monitoringViews.iterator(), new Predicate() {
@Override
public boolean apply(MonitoringView mv) {
return mv.isRunning();
}
});
}
}