Skip to content
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
2 changes: 1 addition & 1 deletion .checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

<module name="LineLength">
<property name="fileExtensions" value="java"/>
<property name="max" value="100"/>
<property name="max" value="120"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>

Expand Down
2 changes: 1 addition & 1 deletion bin/registrar
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ validator/bin/build > /dev/null

echo Running tools version `git describe`

validator/bin/registrar $project_id $site_path $schema_path $*
validator/bin/registrar $project_id $site_path $schema_path $* 2>&1
12 changes: 5 additions & 7 deletions bin/validate
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@ if [ -z "$schema_path" ]; then
false
fi

validator/bin/build
echo Building validator...
validator/bin/build > /dev/null

unset GOOGLE_CLOUD_PROJECT
export GOOGLE_APPLICATION_CREDENTIALS=$PWD/$gcp_cred
echo Using credentials from $GOOGLE_APPLICATION_CREDENTIALS
echo Configured topic is $gcp_topic
echo Configured schema is $schema_path
if [ -n "$site_path" ]; then
echo Configured site path is $site_path
fi
echo Configured site path is $site_path
echo

echo Running tools version `git describe`

validator/bin/validate $schema_path pubsub:$gcp_topic dev $site_path
1 change: 1 addition & 0 deletions pubber/src/main/java/daq/pubber/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class Configuration {
public String registryId;
public String gatewayId;
public String deviceId;
public String sitePath;
public String keyFile = "local/rsa_private.pkcs8";
public byte[] keyBytes;
public String algorithm = "RS256";
Expand Down
15 changes: 10 additions & 5 deletions pubber/src/main/java/daq/pubber/Pubber.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
import daq.udmi.Message.Pointset;
import daq.udmi.Message.PointsetState;
import daq.udmi.Message.State;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -24,6 +21,8 @@
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Pubber {

Expand All @@ -40,9 +39,10 @@ public class Pubber {
private static final int MIN_REPORT_MS = 200;
private static final int DEFAULT_REPORT_MS = 5000;
private static final int CONFIG_WAIT_TIME_MS = 10000;
private static final int STATE_THROTTLE_MS = 1500;
private static final int STATE_THROTTLE_MS = 2000;
private static final String CONFIG_ERROR_STATUS_KEY = "config_error";
private static final int LOGGING_MOD_COUNT = 10;
public static final String KEY_SITE_PATH_FORMAT = "%s/devices/%s/rsa_private.pkcs8";

private final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();

Expand Down Expand Up @@ -163,6 +163,11 @@ private void addPoint(AbstractPoint point) {
}

private void initialize() {
Preconditions.checkNotNull(configuration.deviceId, "configuration deviceId not defined");
if (configuration.sitePath != null) {
configuration.keyFile = String.format(KEY_SITE_PATH_FORMAT, configuration.sitePath,
configuration.deviceId);
}
Preconditions.checkState(mqttPublisher == null, "mqttPublisher already defined");
Preconditions.checkNotNull(configuration.keyFile, "configuration keyFile not defined");
System.err.println("Loading device key file from " + configuration.keyFile);
Expand Down Expand Up @@ -262,8 +267,8 @@ private void publishLogMessage(String deviceId, String logMessage) {

private void publishStateMessage(String deviceId) {
lastStateTimeMs = sleepUntil(lastStateTimeMs + STATE_THROTTLE_MS);
info("Sending state message for device " + deviceId);
deviceState.timestamp = new Date();
info("Sending state message for device " + deviceId + " at " + deviceState.timestamp);
mqttPublisher.publish(deviceId, STATE_TOPIC, deviceState);
}

Expand Down
2 changes: 1 addition & 1 deletion subset/cloud/test_udmi
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ echo Configured schema is $schema_path
echo Target device is $device_id
echo

timeout 60 validator/bin/validate $PWD/$schema_path pubsub:$gcp_topic $service_id-$HOSTNAME || true
timeout 60 validator/bin/validate $PWD/$schema_path pubsub:$gcp_topic $service_id-$HOSTNAME -- || true

function message_report {
message_type=$1
Expand Down
2 changes: 1 addition & 1 deletion validator/.idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions validator/.idea/modules/daq-validator.validator.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions validator/bin/registrar
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ devices_dir=$2
schema_dir=$3
device_filter=$4

echo Using gcloud auth:
gcloud config get-value account || true

echo Using cloud project $project_id
echo Using site config dir $devices_dir
echo Using schema root dir $schema_dir
Expand All @@ -24,6 +27,7 @@ echo Using device filter $device_filter
JAVA=/usr/lib/jvm/java-11-openjdk-amd64/bin/java

error=0
echo java args $project_id $devices_dir $schema_dir $device_filter
$JAVA -cp $jarfile $mainclass $project_id $devices_dir $schema_dir $device_filter || error=$?

echo Registrar complete, exit $error
Expand Down
2 changes: 1 addition & 1 deletion validator/bin/test_schema
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ for schema in $schemas; do

error=0
reltest=${testpath#$rootdir/}
(cd $rootdir; java -jar $jarfile $schemaname $reltest $ignoreset) 2> $output || error=$?
(cd $rootdir; java -jar $jarfile $schemaname $reltest $ignoreset --) 2> $output || error=$?
if [ $force == y ]; then
diff $expected $output || echo Updating $expected && cp $output $expected
else
Expand Down
3 changes: 3 additions & 0 deletions validator/bin/validate
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ if [ ! -f $jarfile ]; then
validator/bin/build
fi

echo Using gcloud auth:
gcloud config get-value account || true

echo Executing validator $schema $target...

echo Validating against schema $schemafile into validations/
Expand Down
Loading