mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
make heartbeat optional
This commit is contained in:
@@ -20,10 +20,13 @@ import io.nosqlbench.nb.api.components.core.NBComponent;
|
|||||||
import io.nosqlbench.nb.api.labels.NBLabels;
|
import io.nosqlbench.nb.api.labels.NBLabels;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A <EM>live</EM> component is one which provides evidence that it is either
|
* A <EM>heartbeat</EM> component is one which provides evidence that it is either
|
||||||
* in a healthy state or that it is not, via a heartbeat mechanism.
|
* in a healthy state or that it is not, via a heartbeat mechanism. This requires
|
||||||
|
* that a component property 'heartbeat' is provides which is the millisecond interval
|
||||||
|
* between beats.
|
||||||
*/
|
*/
|
||||||
public class NBHeartbeatComponent extends NBStatusComponent {
|
public class NBHeartbeatComponent extends NBStatusComponent {
|
||||||
|
|
||||||
@@ -33,8 +36,12 @@ public class NBHeartbeatComponent extends NBStatusComponent {
|
|||||||
|
|
||||||
public NBHeartbeatComponent(NBComponent parentComponent, NBLabels componentSpecificLabelsOnly, Map<String, String> props, String liveLabel) {
|
public NBHeartbeatComponent(NBComponent parentComponent, NBLabels componentSpecificLabelsOnly, Map<String, String> props, String liveLabel) {
|
||||||
super(parentComponent, componentSpecificLabelsOnly, props);
|
super(parentComponent, componentSpecificLabelsOnly, props);
|
||||||
// attaches, no further reference needed
|
getComponentProp("heartbeat")
|
||||||
new ComponentPulse(this, NBLabels.forKV(), liveLabel, Long.parseLong(getComponentProp("heartbeat").orElse("60000")));
|
.map(Long::parseLong)
|
||||||
|
.ifPresent(
|
||||||
|
// attaches, no further reference needed
|
||||||
|
hbmillis -> new ComponentPulse(this, NBLabels.forKV(), liveLabel, hbmillis)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user