Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pubber missingPoint and noConfigAck options #368

Merged
merged 5 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion docs/tools/pubber.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ The following parameters are currently supported from the CLI:
* `extraPoint=<name>` - adds an extra point with the given name to the device
which does not exist in device's metadata with a random value (will trigger
validation additional point error)
* `missingPoint=<name>` - removes the point with the given name (if exists) from
the device's active pointset at initialization (will trigger validation
missing point)
* `extraField=<name>` - adds an extra schema invalidating field to pointset events
(will trigger validation schema error)
* `no_hardware` - omits the `system.hardware` field from state messages (will
* `noHardware` - omits the `system.hardware` field from state messages (will
trigger validation error, missing required field)
* `noConfigAck` - subscribes to the `config` topic with a QoS of 0, therefore
will not send PUBACK's for config messages


More advanced options can be set by by calling pubber directly with the path a
configuration file: `pubber/bin/run path/to/config.json`
Expand Down
2 changes: 2 additions & 0 deletions pubber/src/main/java/daq/pubber/ConfigurationOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
*/
public class ConfigurationOptions {
public Boolean noHardware;
public Boolean noConfigAck;
public String extraPoint;
public String missingPoint;
public String extraField;

}
5 changes: 4 additions & 1 deletion pubber/src/main/java/daq/pubber/MqttPublisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,10 @@ private String getMessageTopic(String deviceId, String topic) {
}

private void subscribeToUpdates(MqttClient client, String deviceId) {
subscribeTopic(client, String.format(CONFIG_UPDATE_TOPIC_FMT, deviceId), QOS_AT_LEAST_ONCE);
boolean noConfigAck = (configuration.options.noConfigAck != null
&& configuration.options.noConfigAck);
int configQos = noConfigAck ? QOS_AT_MOST_ONCE : QOS_AT_LEAST_ONCE;
subscribeTopic(client, String.format(CONFIG_UPDATE_TOPIC_FMT, deviceId), configQos);
subscribeTopic(client, String.format(ERRORS_TOPIC_FMT, deviceId), QOS_AT_MOST_ONCE);
info("Updates subscribed");
}
Expand Down
9 changes: 9 additions & 0 deletions pubber/src/main/java/daq/pubber/Pubber.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,15 @@ private void processDeviceMetadata(Metadata metadata) {

Map<String, PointPointsetModel> points =
metadata.pointset == null ? DEFAULT_POINTS : metadata.pointset.points;

if (configuration.options.missingPoint != null) {
if (points.containsKey(configuration.options.missingPoint)) {
points.remove(configuration.options.missingPoint);
} else {
throw new RuntimeException("missingPoint not in pointset");
}
}

points.forEach((name, point) -> addPoint(makePoint(name, point)));
}

Expand Down