Skip to content

Commit

Permalink
Merge pull request #75 from RADAR-base/release-0.12.3
Browse files Browse the repository at this point in the history
Release 0.12.3
  • Loading branch information
blootsvoets committed Jun 10, 2020
2 parents b61a2ba + c3328e7 commit 3df512f
Show file tree
Hide file tree
Showing 24 changed files with 386 additions and 323 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repositories {
}
dependencies {
implementation group: 'org.radarbase', name: 'radar-commons', version: '0.12.1'
implementation group: 'org.radarbase', name: 'radar-commons', version: '0.12.3'
}
```

Expand Down Expand Up @@ -65,11 +65,11 @@ For server utilities, include `radar-commons-server`:
```gradle
repositories {
jcenter()
maven { url 'http://packages.confluent.io/maven/' }
maven { url 'https://packages.confluent.io/maven/' }
}
dependencies {
implementation group: 'org.radarbase', name: 'radar-commons-server', version: '0.12.1'
implementation group: 'org.radarbase', name: 'radar-commons-server', version: '0.12.3'
}
```

Expand All @@ -78,25 +78,25 @@ For mocking clients of the RADAR-base infrastructure, use that 'radar-commons-te
```gradle
repositories {
jcenter()
maven { url 'http://packages.confluent.io/maven/' }
maven { url 'http://dl.bintray.com/radar-base/org.radarbase' }
maven { url 'https://packages.confluent.io/maven/' }
maven { url 'https://dl.bintray.com/radar-base/org.radarbase' }
}
dependencies {
testImplementation group: 'org.radarbase', name: 'radar-commons-testing', version: '0.12.1'
testImplementation group: 'org.radarbase', name: 'radar-commons-testing', version: '0.12.3'
}
```

Finally, if the schema registry is losing old schemas and your code is not recovering, include `radar-commons-unsafe`. Ensure that it comes in the classpath before any Confluent code. This will override the Confluent Avro deserializer to recover from failure when a message with unknown schema ID is passed.
```gradle
repositories {
jcenter()
maven { url 'http://packages.confluent.io/maven/' }
maven { url 'http://dl.bintray.com/radar-base/org.radarbase' }
maven { url 'https://packages.confluent.io/maven/' }
maven { url 'https://dl.bintray.com/radar-base/org.radarbase' }
}
dependencies {
runtimeOnly group: 'org.radarbase', name: 'radar-commons-unsafe', version: '0.12.1'
runtimeOnly group: 'org.radarbase', name: 'radar-commons-unsafe', version: '0.12.3'
}
```

Expand All @@ -121,7 +121,7 @@ configurations.all {
}
dependencies {
compile group: 'org.radarbase', name: 'radar-commons', version: '0.12.2-SNAPSHOT'
compile group: 'org.radarbase', name: 'radar-commons', version: '0.12.4-SNAPSHOT'
}
```

Expand Down
38 changes: 19 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
plugins {
// Get bintray version
id 'com.jfrog.bintray' version '1.8.4' apply false
id 'com.commercehub.gradle.plugin.avro' version '0.16.0'
id 'com.jfrog.bintray' version '1.8.5' apply false
id 'com.commercehub.gradle.plugin.avro' version '0.19.1'
}

subprojects {
Expand All @@ -29,35 +29,35 @@ subprojects {
// Configuration //
//---------------------------------------------------------------------------//

version = '0.12.2'
version = '0.12.3'
group = 'org.radarbase'
ext.githubRepoName = 'RADAR-base/radar-commons'

ext.slf4jVersion = '1.7.26'
ext.kafkaVersion = '2.3.0'
ext.avroVersion = '1.8.2'
ext.confluentVersion = '5.3.0'
ext.jacksonVersion = '2.9.9.1'
ext.jacksonYamlVersion = '2.9.9'
ext.okhttpVersion = '4.0.1'
ext.junitVersion = '4.12'
ext.mockitoVersion = '2.28.2'
ext.slf4jVersion = '1.7.30'
ext.kafkaVersion = '2.5.0'
ext.avroVersion = '1.9.2'
ext.confluentVersion = '5.5.0'
ext.jacksonVersion = '2.11.0'
ext.jacksonYamlVersion = '2.11.0'
ext.okhttpVersion = '4.7.2'
ext.junitVersion = '4.13'
ext.mockitoVersion = '3.3.3'
ext.hamcrestVersion = '1.3'
ext.codacyVersion = '6.0.0'
ext.radarSchemasVersion = '0.5.1'
ext.orgJsonVersion = '20180813'
ext.codacyVersion = '7.9.0'
ext.radarSchemasVersion = '0.5.9'
ext.orgJsonVersion = '20200518'

ext.githubUrl = "https://github.com/$githubRepoName"
ext.issueUrl = "https://github.com/$githubRepoName/issues"
ext.website = 'http://radar-base.org'
ext.website = 'https://radar-base.org'

//---------------------------------------------------------------------------//
// Dependencies //
//---------------------------------------------------------------------------//
repositories {
jcenter()
maven { url 'http://packages.confluent.io/maven/' }
maven { url 'http://dl.bintray.com/typesafe/maven-releases' }
maven { url 'https://packages.confluent.io/maven/' }
maven { url 'https://dl.bintray.com/typesafe/maven-releases' }
flatDir {
dirs "${project.rootDir}/libs"
}
Expand Down Expand Up @@ -111,5 +111,5 @@ subprojects {
}

wrapper {
gradleVersion '5.5.1'
gradleVersion '6.3'
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
33 changes: 14 additions & 19 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
Expand Down Expand Up @@ -154,19 +154,19 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
i=`expr $i + 1`
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi

Expand All @@ -175,14 +175,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
APP_ARGS=`save "$@"`

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi

exec "$JAVACMD" "$@"
3 changes: 3 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

Expand Down
2 changes: 1 addition & 1 deletion radar-commons-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dependencies {
testImplementation group: 'org.radarcns', name: 'radar-schemas-commons', version: radarSchemasVersion
// Direct producer uses KafkaAvroSerializer if initialized
testImplementation group: 'junit', name: 'junit', version: junitVersion
testRuntime group: 'org.slf4j', name: 'slf4j-simple', version: slf4jVersion
testRuntimeOnly group: 'org.slf4j', name: 'slf4j-simple', version: slf4jVersion
}

apply from: '../gradle/publishing.gradle'
Expand Down
2 changes: 1 addition & 1 deletion radar-commons-testing/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dependencies {
api group: 'org.apache.avro', name: 'avro', version: avroVersion
api group: 'org.radarcns', name: 'radar-schemas-commons', version: radarSchemasVersion

implementation group: 'com.opencsv', name: 'opencsv', version: '4.6'
implementation group: 'com.opencsv', name: 'opencsv', version: '5.2'
implementation group: 'com.fasterxml.jackson.core' , name: 'jackson-databind' , version: jacksonVersion
implementation group: 'org.apache.kafka', name: 'kafka-clients', version: kafkaVersion
implementation (group: 'io.confluent', name: 'kafka-avro-serializer', version: confluentVersion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.radarbase.mock;

import com.opencsv.exceptions.CsvValidationException;
import java.io.IOException;
import org.apache.avro.SchemaValidationException;
import org.radarbase.data.Record;
Expand Down Expand Up @@ -50,6 +51,8 @@ public void send() throws IOException {
}
} catch (SchemaValidationException e) {
throw new IOException("Failed to match schemas", e);
} catch (CsvValidationException e) {
throw new IOException("Failed to read CSV file", e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@

package org.radarbase.mock;

import static io.confluent.kafka.serializers.AbstractKafkaAvroSerDeConfig.SCHEMA_REGISTRY_URL_CONFIG;
import static io.confluent.kafka.serializers.AbstractKafkaSchemaSerDeConfig.SCHEMA_REGISTRY_URL_CONFIG;
import static org.apache.kafka.clients.producer.ProducerConfig.BOOTSTRAP_SERVERS_CONFIG;
import static org.apache.kafka.clients.producer.ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG;
import static org.apache.kafka.clients.producer.ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG;

import com.opencsv.exceptions.CsvValidationException;
import io.confluent.kafka.serializers.KafkaAvroSerializer;
import java.io.IOException;
import java.nio.file.Path;
Expand Down Expand Up @@ -59,7 +60,7 @@
* A Mock Producer class that can be used to stream data. It can use MockFileSender and MockDevice
* for testing purposes, with direct or indirect streaming.
*/
@SuppressWarnings("PMD.DoNotCallSystemExit")
@SuppressWarnings("PMD")
public class MockProducer {

private static final Logger logger = LoggerFactory.getLogger(MockProducer.class);
Expand Down Expand Up @@ -120,6 +121,13 @@ public MockProducer(BasicMockConfig mockConfig, Path root) throws IOException {
for (int i = 0; i < mockFiles.size(); i++) {
files.add(new MockFileSender(tmpSenders.get(i + numDevices), mockFiles.get(i)));
}
} catch (CsvValidationException ex) {
if (tmpSenders != null) {
for (KafkaSender sender : tmpSenders) {
sender.close();
}
}
throw new IOException("Cannot read CSV file", ex);
} catch (Exception ex) {
if (tmpSenders != null) {
for (KafkaSender sender : tmpSenders) {
Expand Down Expand Up @@ -185,7 +193,7 @@ private List<KafkaSender> createRestSenders(int numDevices,

/** Start sending data. */
public void start() throws IOException {
for (MockDevice device : devices) {
for (MockDevice<?> device : devices) {
device.start();
}
for (MockFileSender file : files) {
Expand All @@ -197,11 +205,11 @@ public void start() throws IOException {
public void shutdown() throws IOException, InterruptedException, SchemaValidationException {
if (!devices.isEmpty()) {
logger.info("Shutting down mock devices");
for (MockDevice device : devices) {
for (MockDevice<?> device : devices) {
device.shutdown();
}
logger.info("Waiting for mock devices to finish...");
for (MockDevice device : devices) {
for (MockDevice<?> device : devices) {
device.join(5_000L);
}
}
Expand All @@ -210,7 +218,7 @@ public void shutdown() throws IOException, InterruptedException, SchemaValidatio
sender.close();
}

for (MockDevice device : devices) {
for (MockDevice<?> device : devices) {
device.checkException();
}
}
Expand Down Expand Up @@ -345,7 +353,7 @@ private List<RecordGenerator<ObservationKey>> createGenerators(List<MockDataConf
}

private List<MockCsvParser<ObservationKey>> createMockFiles(List<MockDataConfig> configs,
Path dataRoot) throws IOException {
Path dataRoot) throws IOException, CsvValidationException {

List<MockCsvParser<ObservationKey>> result = new ArrayList<>(configs.size());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.radarbase.mock.data;

import com.opencsv.CSVReader;
import com.opencsv.exceptions.CsvValidationException;
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
Expand Down Expand Up @@ -55,7 +56,8 @@ public class MockCsvParser<K extends SpecificRecord> implements Closeable {
* @param root parent directory of the data file.
* @throws IllegalArgumentException if the second row has the wrong number of columns
*/
public MockCsvParser(MockDataConfig config, Path root) throws IOException {
public MockCsvParser(MockDataConfig config, Path root)
throws IOException, CsvValidationException {
//noinspection unchecked
topic = config.parseAvroTopic();

Expand All @@ -80,7 +82,7 @@ public AvroTopic getTopic() {
* @throws IllegalStateException if a next row is not available
* @throws IOException if the next row could not be read
*/
public Record<K, SpecificRecord> next() throws IOException {
public Record<K, SpecificRecord> next() throws IOException, CsvValidationException {
if (!hasNext()) {
throw new IllegalStateException("No next record available");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.radarbase.mock.data;

import com.opencsv.exceptions.CsvValidationException;
import java.io.IOException;
import java.nio.file.Path;
import org.apache.avro.specific.SpecificRecord;
Expand Down Expand Up @@ -71,7 +72,7 @@ public void validate() {

checkDuration();
checkFrequency(line);
} catch (IOException e) {
} catch (IOException | CsvValidationException e) {
error("Cannot open file", -1, e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.radarbase.mock.model;

import com.opencsv.exceptions.CsvValidationException;
import java.io.IOException;
import java.nio.file.Path;
import java.util.HashMap;
Expand Down Expand Up @@ -81,9 +82,11 @@ public Map<MockDataConfig, ExpectedValue> simulate() throws IOException {
}

expectedValue.put(config, value);
} catch (CsvValidationException ex) {
throw new IOException(ex);
}
}

return expectedValue;
}
}
}
Loading

0 comments on commit 3df512f

Please sign in to comment.