Skip to content

Commit

Permalink
Merge pull request #38 from RADAR-CNS/v0.6-alpha.1_release
Browse files Browse the repository at this point in the history
Release for v0.6 alpha.1
  • Loading branch information
blootsvoets committed Oct 12, 2017
2 parents ac8631f + 56d0c8d commit 7a82b2e
Show file tree
Hide file tree
Showing 49 changed files with 596 additions and 318 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ log/
# Gradle
.gradle/
.gradletasknamecache
local.properties

# Build
build/
Expand All @@ -22,3 +23,4 @@ build/
# Generated compile files
/out/
backend.log
local.properties
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repositories {
}
dependencies {
compile group: 'org.radarcns', name: 'radar-commons', version: '0.5'
compile group: 'org.radarcns', name: 'radar-commons', version: '0.6-alpha.1'
}
```

Expand All @@ -26,7 +26,7 @@ repositories {
}
dependencies {
testCompile group: 'org.radarcns', name: 'radar-commons-testing', version: '0.5'
testCompile group: 'org.radarcns', name: 'radar-commons-testing', version: '0.6-alpha.1'
}
```

Expand All @@ -51,7 +51,7 @@ configurations.all {
}
dependencies {
compile group: 'org.radarcns', name: 'radar-commons', version: '0.5.1-SNAPSHOT', changing: true
compile group: 'org.radarcns', name: 'radar-commons', version: '0.6-SNAPSHOT', changing: true
}
```

Expand Down
44 changes: 25 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@

plugins {
// Get bintray version
id "com.jfrog.bintray" version "1.7.3"
id "com.jfrog.artifactory" version "4.4.18"
id 'com.jfrog.bintray' version '1.7.3'
id 'com.jfrog.artifactory' version '4.4.18'
}

apply plugin: "com.jfrog.artifactory"

allprojects {
// Apply the plugins
apply plugin: 'java'
Expand All @@ -32,29 +30,30 @@ allprojects {
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven-publish'
apply plugin: 'jacoco'
apply plugin: 'com.jfrog.artifactory'

//---------------------------------------------------------------------------//
// Configuration //
//---------------------------------------------------------------------------//

version = '0.5'
version = '0.6-alpha.1'
group = 'org.radarcns'
ext.githubRepoName = 'RADAR-CNS/RADAR-Commons'

ext.slf4jVersion = '1.7.21'
ext.kafkaVersion = '0.10.2.1'
ext.avroVersion = '1.8.1'
ext.confluentVersion = '3.1.2'
ext.kafkaVersion = '0.11.0.1'
ext.avroVersion = '1.8.2'
ext.confluentVersion = '3.3.0'
ext.log4jVersion = '2.7'
ext.jacksonVersion = '2.8.5'
ext.okhttpVersion = '3.6.0'
ext.okioVersion = '1.11.0'
ext.okhttpVersion = '3.8.0'
ext.junitVersion = '4.12'
ext.mockitoVersion = '2.2.29'
ext.mathVersion = '3.0'
ext.hamcrestVersion = '1.3'
ext.codacyVersion = '1.0.10'
ext.radarSchemasVersion = '0.1'
ext.radarSchemasVersion = '0.2-alpha.3-SNAPSHOT'
ext.jsonVersion = '20170516'

ext.githubUrl = 'https://github.com/' + githubRepoName + '.git'
ext.issueUrl = 'https://github.com/' + githubRepoName + '/issues'
Expand All @@ -67,6 +66,9 @@ allprojects {
jcenter()
maven { url 'http://packages.confluent.io/maven/' }
maven { url 'http://dl.bintray.com/typesafe/maven-releases' }
flatDir {
dirs "${project.rootDir}/libs"
}
}

ext.pomConfig = {
Expand Down Expand Up @@ -191,14 +193,24 @@ configurations {
codacy
}

configurations.compile {
resolutionStrategy.cacheChangingModulesFor 0, 'SECONDS'
}

// In this section you declare where to find the dependencies of your project
repositories {
maven { url 'https://jitpack.io' }
maven { url 'https://oss.jfrog.org/artifactory/oss-snapshot-local' }
}

// In this section you declare the dependencies for your production and test code
dependencies {
api group: 'org.apache.avro', name: 'avro', version: avroVersion
api (group: 'org.apache.avro', name: 'avro', version: avroVersion) {
exclude group: 'org.xerial.snappy', module: 'snappy-java'
exclude group: 'com.thoughtworks.paranamer', module: 'paranamer'
exclude group: 'org.apache.commons', module: 'commons-compress'
exclude group: 'org.tukaani', module: 'xz'
}

// to implement producers and consumers
api group: 'org.apache.kafka', name: 'kafka-clients', version: kafkaVersion
Expand All @@ -207,9 +219,7 @@ dependencies {
// For POJO classes and ConfigLoader
implementation group: 'com.fasterxml.jackson.core' , name: 'jackson-databind' , version: jacksonVersion
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: jacksonVersion

// The REST data is serialized with okio
implementation group: 'com.squareup.okio', name: 'okio', version: okioVersion
implementation group: 'org.json', name: 'json', version: jsonVersion

// The production code uses the SLF4J logging API at compile time
implementation group: 'org.slf4j', name:'slf4j-api', version: slf4jVersion
Expand Down Expand Up @@ -352,10 +362,6 @@ artifactory {

artifactoryPublish {
publications('RadarCommonsPublication')
publishBuildInfo = true //Publish build-info to Artifactory (true by default)
publishArtifacts = true //Publish artifacts to Artifactory (true by default)
publishPom = true //Publish generated POM files to Artifactory (true by default).
publishIvy = false //Publish generated Ivy descriptor files to Artifactory (true by default).
}

task wrapper(type: Wrapper) {
Expand Down
1 change: 1 addition & 0 deletions libs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.jar
File renamed without changes.
23 changes: 22 additions & 1 deletion testing/build.gradle → radar-commons-testing/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ ext.description = 'RADAR Common testing library mocking code and utilities.'
targetCompatibility = '1.7'
sourceCompatibility = '1.7'

repositories {
maven { url 'https://oss.jfrog.org/artifactory/oss-snapshot-local' }
}

dependencies {
api rootProject
api group: 'org.apache.avro', name: 'avro', version: avroVersion
Expand Down Expand Up @@ -136,4 +140,21 @@ bintray {
released = new Date()
}
}
}
}


artifactory {
contextUrl = 'https://oss.jfrog.org/artifactory'
publish {
repository {
repoKey = 'oss-snapshot-local'
username = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
password = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
maven = true
}
}
}

artifactoryPublish {
publications('RadarCommonsTestingPublication')
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.io.IOException;
import org.apache.avro.specific.SpecificRecord;
import org.radarcns.data.Record;
import org.radarcns.key.MeasurementKey;
import org.radarcns.kafka.ObservationKey;
import org.radarcns.mock.data.MockCsvParser;
import org.radarcns.producer.KafkaSender;
import org.radarcns.producer.KafkaTopicSender;
Expand All @@ -33,7 +33,7 @@ public class MockFileSender {
private final KafkaSender sender;
private final MockCsvParser parser;

public MockFileSender(KafkaSender<MeasurementKey, SpecificRecord> sender,
public MockFileSender(KafkaSender<ObservationKey, SpecificRecord> sender,
MockCsvParser parser) {
this.parser = parser;
this.sender = sender;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
import org.radarcns.config.ServerConfig;
import org.radarcns.config.YamlConfigLoader;
import org.radarcns.data.SpecificRecordEncoder;
import org.radarcns.empatica.EmpaticaE4Acceleration;
import org.radarcns.empatica.EmpaticaE4BatteryLevel;
import org.radarcns.empatica.EmpaticaE4BloodVolumePulse;
import org.radarcns.empatica.EmpaticaE4ElectroDermalActivity;
import org.radarcns.empatica.EmpaticaE4InterBeatInterval;
import org.radarcns.empatica.EmpaticaE4Temperature;
import org.radarcns.key.MeasurementKey;
import org.radarcns.passive.empatica.EmpaticaE4Acceleration;
import org.radarcns.passive.empatica.EmpaticaE4BatteryLevel;
import org.radarcns.passive.empatica.EmpaticaE4BloodVolumePulse;
import org.radarcns.passive.empatica.EmpaticaE4ElectroDermalActivity;
import org.radarcns.passive.empatica.EmpaticaE4InterBeatInterval;
import org.radarcns.passive.empatica.EmpaticaE4Temperature;
import org.radarcns.kafka.ObservationKey;
import org.radarcns.mock.config.BasicMockConfig;
import org.radarcns.mock.config.MockDataConfig;
import org.radarcns.mock.data.MockCsvParser;
Expand All @@ -64,9 +64,9 @@ public class MockProducer {

private static final Logger logger = LoggerFactory.getLogger(MockProducer.class);

private final List<MockDevice<MeasurementKey>> devices;
private final List<MockDevice<ObservationKey>> devices;
private final List<MockFileSender> files;
private final List<KafkaSender<MeasurementKey, SpecificRecord>> senders;
private final List<KafkaSender<ObservationKey, SpecificRecord>> senders;
private final SchemaRetriever retriever;

/**
Expand All @@ -89,7 +89,7 @@ public MockProducer(BasicMockConfig mockConfig, File root) throws IOException {
int numDevices = mockConfig.getNumberOfDevices();

retriever = new SchemaRetriever(mockConfig.getSchemaRegistry(), 10);
List<KafkaSender<MeasurementKey, SpecificRecord>> tmpSenders = null;
List<KafkaSender<ObservationKey, SpecificRecord>> tmpSenders = null;

try {
devices = new ArrayList<>(numDevices);
Expand All @@ -100,8 +100,8 @@ public MockProducer(BasicMockConfig mockConfig, File root) throws IOException {
dataConfigs = defaultDataConfig();
}

List<RecordGenerator<MeasurementKey>> generators;
List<MockCsvParser<MeasurementKey>> mockFiles;
List<RecordGenerator<ObservationKey>> generators;
List<MockCsvParser<ObservationKey>> mockFiles;
try {
generators = createGenerators(dataConfigs);
mockFiles = createMockFiles(dataConfigs, root);
Expand All @@ -117,7 +117,7 @@ public MockProducer(BasicMockConfig mockConfig, File root) throws IOException {
String sourceId = "SourceID_";

for (int i = 0; i < numDevices; i++) {
MeasurementKey key = new MeasurementKey(userId + i, sourceId + i);
ObservationKey key = new ObservationKey("test", userId + i, sourceId + i);
devices.add(new MockDevice<>(tmpSenders.get(i), key, generators));
}
}
Expand All @@ -138,7 +138,7 @@ public MockProducer(BasicMockConfig mockConfig, File root) throws IOException {
senders = tmpSenders;
}

private List<KafkaSender<MeasurementKey, SpecificRecord>> createSenders(
private List<KafkaSender<ObservationKey, SpecificRecord>> createSenders(
BasicMockConfig mockConfig, int numDevices) {

if (mockConfig.isDirectProducer()) {
Expand All @@ -150,28 +150,28 @@ private List<KafkaSender<MeasurementKey, SpecificRecord>> createSenders(
}

/** Create senders that directly produce data to Kafka. */
private List<KafkaSender<MeasurementKey, SpecificRecord>> createDirectSenders(int numDevices,
private List<KafkaSender<ObservationKey, SpecificRecord>> createDirectSenders(int numDevices,
SchemaRetriever retriever, String brokerPaths) {
List<KafkaSender<MeasurementKey, SpecificRecord>> result = new ArrayList<>(numDevices);
List<KafkaSender<ObservationKey, SpecificRecord>> result = new ArrayList<>(numDevices);
for (int i = 0; i < numDevices; i++) {
Properties properties = new Properties();
properties.put(KEY_SERIALIZER_CLASS_CONFIG, KafkaAvroSerializer.class);
properties.put(VALUE_SERIALIZER_CLASS_CONFIG, KafkaAvroSerializer.class);
properties.put(SCHEMA_REGISTRY_CONFIG, retriever);
properties.put(BOOTSTRAP_SERVERS_CONFIG, brokerPaths);

result.add(new DirectSender<MeasurementKey, SpecificRecord>(properties));
result.add(new DirectSender<ObservationKey, SpecificRecord>(properties));
}
return result;
}

/** Create senders that produce data to Kafka via the REST proxy. */
private List<KafkaSender<MeasurementKey, SpecificRecord>> createRestSenders(int numDevices,
private List<KafkaSender<ObservationKey, SpecificRecord>> createRestSenders(int numDevices,
SchemaRetriever retriever, ServerConfig restProxy, boolean useCompression) {
List<KafkaSender<MeasurementKey, SpecificRecord>> result = new ArrayList<>(numDevices);
List<KafkaSender<ObservationKey, SpecificRecord>> result = new ArrayList<>(numDevices);
ConnectionState sharedState = new ConnectionState(10, TimeUnit.SECONDS);
RestSender.Builder<MeasurementKey, SpecificRecord> restBuilder =
new RestSender.Builder<MeasurementKey, SpecificRecord>()
RestSender.Builder<ObservationKey, SpecificRecord> restBuilder =
new RestSender.Builder<ObservationKey, SpecificRecord>()
.server(restProxy)
.schemaRetriever(retriever)
.useCompression(useCompression)
Expand All @@ -181,7 +181,7 @@ private List<KafkaSender<MeasurementKey, SpecificRecord>> createRestSenders(int
.connectionTimeout(10, TimeUnit.SECONDS);

for (int i = 0; i < numDevices; i++) {
RestSender<MeasurementKey, SpecificRecord> firstSender = restBuilder
RestSender<ObservationKey, SpecificRecord> firstSender = restBuilder
.connectionPool(new ManagedConnectionPool())
.build();

Expand Down Expand Up @@ -214,7 +214,7 @@ public void shutdown() throws IOException, InterruptedException {
device.join(5_000L);
}
logger.info("Closing channels");
for (KafkaSender<MeasurementKey, SpecificRecord> sender : senders) {
for (KafkaSender<ObservationKey, SpecificRecord> sender : senders) {
sender.close();
}
retriever.close();
Expand Down Expand Up @@ -344,27 +344,27 @@ private List<MockDataConfig> defaultDataConfig() {
return Arrays.asList(acceleration, battery, bvp, eda, ibi, temperature);
}

private List<RecordGenerator<MeasurementKey>> createGenerators(List<MockDataConfig> configs)
private List<RecordGenerator<ObservationKey>> createGenerators(List<MockDataConfig> configs)
throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException,
InvocationTargetException {

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

for (MockDataConfig config : configs) {
if (config.getDataFile() == null) {
result.add(new RecordGenerator<>(config, MeasurementKey.class));
result.add(new RecordGenerator<>(config, ObservationKey.class));
}
}

return result;
}

private List<MockCsvParser<MeasurementKey>> createMockFiles(List<MockDataConfig> configs,
private List<MockCsvParser<ObservationKey>> createMockFiles(List<MockDataConfig> configs,
File dataRoot)
throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException,
InvocationTargetException, IOException {

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

File parent = dataRoot;
if (parent == null) {
Expand All @@ -373,7 +373,7 @@ private List<MockCsvParser<MeasurementKey>> createMockFiles(List<MockDataConfig>

for (MockDataConfig config : configs) {
if (config.getDataFile() != null) {
result.add(new MockCsvParser<MeasurementKey>(config, parent));
result.add(new MockCsvParser<ObservationKey>(config, parent));
}
}

Expand Down
Loading

0 comments on commit 7a82b2e

Please sign in to comment.