Skip to content

Commit

Permalink
Merge pull request #92 from RADAR-base/release-0.3.1
Browse files Browse the repository at this point in the history
Release 0.3.1
  • Loading branch information
blootsvoets committed Jan 29, 2018
2 parents 7b731cb + 0297e9f commit b076b5f
Show file tree
Hide file tree
Showing 34 changed files with 444 additions and 138 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,4 @@ docker-compose run --rm tools radar-schemas-tools register http://schema-registr
docker-compose run --rm tools radar-schemas-tools create zookeeper-1:2181
# run source-catalogue webservice
docker-compose run --rm tools radar-schemas-tools serve -p <portnumber>

```
1 change: 1 addition & 0 deletions commons/catalogue/unit.avsc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"RADAIAN_PER_SEC",
"RMSSD_IN_MILLI_SEC",
"SECOND",
"MICRO_VOLT",
"UNKNOWN"
]
}
13 changes: 13 additions & 0 deletions commons/passive/emotion/emotion_faros_acceleration.avsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"namespace": "org.radarcns.passive.emotion",
"type": "record",
"name": "EmotionFarosAcceleration",
"doc": "Data from 3-axis accelerometer sensor of a eMotion Faros device.",
"fields": [
{ "name": "time", "type": "double", "doc": "Device timestamp in UTC (s)." },
{ "name": "timeReceived", "type": "double", "doc": "Device receiver timestamp in UTC (s)." } ,
{ "name": "x", "type": "float", "doc": "Acceleration in the x-axis (g)." },
{ "name": "y", "type": "float", "doc": "Acceleration in the y-axis (g)." },
{ "name": "z", "type": "float", "doc": "Acceleration in the z-axis (g)." }
]
}
11 changes: 11 additions & 0 deletions commons/passive/emotion/emotion_faros_battery_level.avsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"namespace": "org.radarcns.passive.emotion",
"type": "record",
"name": "EmotionFarosBatteryLevel",
"doc": "Battery level of a eMotion Faros device.",
"fields": [
{ "name": "time", "type": "double", "doc": "Device timestamp in UTC (s)." },
{ "name": "timeReceived", "type": "double", "doc": "Device receiver timestamp in UTC (s)." },
{ "name": "batteryLevel", "type": "float", "doc": "Battery level from 0 to 1. Note that the battery level is a rough estimate." }
]
}
13 changes: 13 additions & 0 deletions commons/passive/emotion/emotion_faros_ecg.avsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"namespace": "org.radarcns.passive.emotion",
"type": "record",
"name": "EmotionFarosEcg",
"doc": "Data from eMotion Faros' multi-channel electrocardiography electrodes. Not all Faros models possess the same number of channels, so the second and third channels are optional.",
"fields": [
{ "name": "time", "type": "double", "doc": "Device timestamp in UTC (s)." },
{ "name": "timeReceived", "type": "double", "doc": "Device receiver timestamp in UTC (s)." } ,
{ "name": "ecgChannel1", "type": "float", "doc": "ECG signal from the first channel (µV)." },
{ "name": "ecgChannel2", "type": ["null", "float"], "doc": "ECG signal from the second channel (µV). Null if the device does not have at least two channels.", "default": null },
{ "name": "ecgChannel3", "type": ["null", "float"], "doc": "ECG signal from the first channel (µV). Null if the device does not have at least two three channels.", "default": null }
]
}
11 changes: 11 additions & 0 deletions commons/passive/emotion/emotion_faros_inter_beat_interval.avsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"namespace": "org.radarcns.passive.emotion",
"type": "record",
"name": "EmotionFarosInterBeatInterval",
"doc": "Time between two successive R-peaks (RR-interval), as calculated by a eMotion Faros device from the ECG signal. You can compute the heart rate as (60 / ibi).",
"fields": [
{"name": "time", "type": "double", "doc": "Device timestamp in UTC (s)." },
{"name": "timeReceived", "type": "double", "doc": "Device receiver timestamp in UTC (s)." },
{"name": "interBeatInterval", "type": "float", "doc": "Duration (s) of the detected inter beat interval." }
]
}
11 changes: 11 additions & 0 deletions commons/passive/emotion/emotion_faros_temperature.avsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"namespace": "org.radarcns.passive.emotion",
"type": "record",
"name": "EmotionFarosTemperature",
"doc": "Data from an eMotion Faros' temperature sensor.",
"fields": [
{"name": "time", "type": "double", "doc": "Device timestamp in UTC (s)." },
{"name": "timeReceived", "type": "double", "doc": "Device receiver timestamp in UTC (s)." },
{"name": "temperature", "type": "float", "doc": "Skin temperature (°C) converted from analog-to-digital converter (ADC) values. Conversion is reliable between 35 and 45 degrees Celcius." }
]
}
11 changes: 11 additions & 0 deletions commons/stream/source_statistics.avsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"namespace": "org.radarcns.stream",
"type": "record",
"name": "SourceStatistics",
"doc": "Statistics about single sources.",
"version": "1.0.0",
"fields": [
{ "name": "timeStart", "type": "double", "doc": "First time (seconds since the UNIX Epoch) that a source streamed any data." },
{ "name": "timeEnd", "type": "double", "doc": "Last time (seconds since the UNIX Epoch) that a source streamed any data." }
]
}
6 changes: 3 additions & 3 deletions java-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ repositories {
dependencies {
// Commons schemas (backend, passive remote monitoring app)
compile 'org.radarcns:radar-schemas-commons:0.3'
compile 'org.radarcns:radar-schemas-commons:0.3.1'
// REST API schemas (REST API, testing)
compile 'org.radarcns:radar-schemas-restapi:0.3'
compile 'org.radarcns:radar-schemas-restapi:0.3.1'
// Questionnaire schemas (active remote monitoring app)
compile 'org.radarcns:radar-schemas-tools:0.3'
compile 'org.radarcns:radar-schemas-tools:0.3.1'
}
```
Usually, you only need to include the schemas you actually need in your dependencies.
Expand Down
22 changes: 11 additions & 11 deletions java-sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ subprojects {
apply plugin: 'idea'

// Configuration
version = '0.3'
version = '0.3.1'
group = 'org.radarcns'
ext.githubRepoName = 'RADAR-CNS/RADAR-Schemas'

Expand Down Expand Up @@ -128,17 +128,17 @@ subprojects {
downloadSources = true
}
}
}

task downloadDependencies {
description "Pre-downloads *most* dependencies"
doLast {
configurations.getAsMap().each { name, config ->
println "Retrieving dependencies for $name"
try {
config.files
} catch (e) {
project.logger.info e.message // some cannot be resolved, silentlyish skip them
task downloadDependencies {
description "Pre-downloads *most* dependencies"
doLast {
configurations.getAsMap().each { name, config ->
println "Retrieving dependencies for $name"
try {
config.files
} catch (e) {
project.logger.info e.message // some cannot be resolved, silentlyish skip them
}
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions java-sdk/radar-schemas-tools/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# RADAR Schemas tools

A number of tools are provided with RADAR-Schemas. They are most easily accessed by using the docker
image as described in the main readme. Below is more information about the schema validation that
the tools can perform.

The RADAR Schemas Validator checks if the `Schema Catalog` is in a valid state.

It first checks the folder structure, it has to be compliant with:
Expand Down Expand Up @@ -70,9 +74,8 @@ All tests are enable by default.

```yaml
validation:
schema_to_skip:
- record_name_check: [ ENABLE | DISABLE ]
fields:
org.radarcns.passive.biovotion.BiovotionVSMSpO2:
- fields:
- fieldnameOne
- fieldnameTwo
```
13 changes: 9 additions & 4 deletions java-sdk/radar-schemas-tools/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ plugins {
id 'checkstyle'
id 'pmd'
id 'application'
id 'com.jfrog.artifactory'
}

apply plugin: 'com.jfrog.artifactory'

ext.artifactName = 'radar-schemas-tools'
ext.description = 'RADAR Schemas specification and validation tools.'

Expand All @@ -23,8 +22,9 @@ sourceSets {

ext.junitVersion = '4.12'
ext.slf4jVersion = '1.7.25'
ext.jettyVersion = '9.4.7.v20170914'
ext.jerseyVersion = '2.9'
ext.jettyVersion = '9.4.8.v20171121'
ext.jerseyVersion = '2.26'

dependencies {
api group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.10'
api group: 'javax.validation', name: 'validation-api', version: '2.0.0.Final'
Expand Down Expand Up @@ -116,6 +116,11 @@ publishing {
root.appendNode('name', artifactName)
root.appendNode('url', githubUrl)
root.children().last() + pomConfig
root.dependencies.'*'.findAll() {
it.artifactId.text() == 'slf4j-simple'
}.each() {
it.parent().remove(it)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import static java.util.stream.Collectors.toList;

/**
* TODO.
* Command line app containing a source catalogue.
*/
@SuppressWarnings("PMD.SystemPrintln")
public class CommandLineApp {
Expand All @@ -60,6 +60,12 @@ public class CommandLineApp {
private final SourceCatalogue catalogue;
private final Path root;

/**
* Command line app started at a RADAR-Schemas root. The source catalogue is read from the
* {@code specifications} directory in that root.
* @param root path to the root of a RADAR-Schemas directory.
* @throws IOException if the source catalogue cannot be loaded.
*/
public CommandLineApp(Path root) throws IOException {
this.root = root;
this.catalogue = SourceCatalogue.load(root);
Expand Down Expand Up @@ -163,6 +169,7 @@ private Map<String, Map<String, String>> getTopicsInfoVerbose(boolean prettyPrin
DataTopic::getTopic, d -> d.toString(prettyPrint)))));
}

/** Command to execute. */
public static void main(String... args) {
SortedMap<String, SubCommand> subCommands = commandsToMap(
KafkaTopics.command(),
Expand Down Expand Up @@ -221,6 +228,7 @@ private static SortedMap<String, SubCommand> commandsToMap(SubCommand... command
return map;
}

/** Command to list the topics. */
private static SubCommand listCommand() {
return new SubCommand() {
@Override
Expand Down Expand Up @@ -262,13 +270,21 @@ public void addParser(ArgumentParser parser) {
};
}

/**
* Create a pattern to match given topic. If the exact match is non-null, it is returned
* as an exact match, otherwise if regex is non-null, it is used, and otherwise
* {@code null} is returned.
* @param exact string that should be exactly matched.
* @param regex string that should be matched as a regex.
* @return pattern or {@code null} if both exact and regex are {@code null}.
*/
public static Pattern matchTopic(String exact, String regex) {
if (exact != null) {
return Pattern.compile("^" + Pattern.quote(exact) + "$");
}
if (regex != null) {
} else if (regex != null) {
return Pattern.compile(regex);
} else {
return null;
}
return null;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package org.radarcns.schema.registration;

import static org.radarcns.schema.CommandLineApp.matchTopic;

import java.io.Closeable;
import java.util.Optional;
import java.util.Properties;
import java.util.regex.Pattern;
import kafka.admin.AdminUtils;
import kafka.admin.RackAwareMode;
import kafka.utils.ZKStringSerializer;
Expand All @@ -8,22 +14,15 @@
import net.sourceforge.argparse4j.inf.Namespace;
import org.I0Itec.zkclient.ZkClient;
import org.I0Itec.zkclient.ZkConnection;
import org.I0Itec.zkclient.exception.ZkException;
import org.I0Itec.zkclient.exception.ZkMarshallingError;
import org.I0Itec.zkclient.serialize.ZkSerializer;
import org.apache.zookeeper.KeeperException;
import org.radarcns.schema.CommandLineApp;
import org.radarcns.schema.specification.SourceCatalogue;
import org.radarcns.schema.util.SubCommand;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Closeable;
import java.util.Optional;
import java.util.Properties;
import java.util.regex.Pattern;

import static org.radarcns.schema.CommandLineApp.matchTopic;

/**
* Registers Kafka topics with Zookeeper.
*/
Expand Down Expand Up @@ -60,10 +59,11 @@ public Object deserialize(byte[] bytes) throws ZkMarshallingError {
* waiting for at most 200 seconds.
* @param brokers number of brokers to wait for
* @return whether the brokers where available
* @throws InterruptedException
* @throws KeeperException
* @throws InterruptedException when waiting for the brokers is interrepted.
* @throws ZkException if the Zookeeper instance cannot be reached or returns an unexpected
* result.
*/
public boolean waitForBrokers(int brokers) throws InterruptedException, KeeperException {
public boolean waitForBrokers(int brokers) throws InterruptedException, ZkException {
boolean brokersAvailable = false;
int sleep = 2;
for (int tries = 0; tries < 10; tries++) {
Expand Down Expand Up @@ -124,7 +124,7 @@ public boolean createTopic(String topic, int partitions, int replication) {
}
}

public int getNumberOfBrokers() throws KeeperException, InterruptedException {
public int getNumberOfBrokers() throws ZkException {
return zkUtils.getAllBrokersInCluster().length();
}

Expand Down Expand Up @@ -185,8 +185,8 @@ public int execute(Namespace options, CommandLineApp app) {
return result.get() ? 0 : 1;
}
}
} catch (InterruptedException | KeeperException e) {
logger.error("Cannot retrieve number of active Kafka brokers."
} catch (InterruptedException | ZkException e) {
logger.error("Cannot retrieve number of addActive Kafka brokers."
+ " Please check that Zookeeper is running.");
return 1;
}
Expand Down
Loading

0 comments on commit b076b5f

Please sign in to comment.