Skip to content

Commit

Permalink
Merge pull request #21 from RADAR-CNS/v0.4.1_release
Browse files Browse the repository at this point in the history
V0.4.1 release
  • Loading branch information
blootsvoets authored Jul 6, 2017
2 parents bab1ad6 + 070823d commit a43961d
Show file tree
Hide file tree
Showing 20 changed files with 556 additions and 130 deletions.
43 changes: 26 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,38 @@ language: java
jdk:
- oraclejdk8
sudo: false
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/3.*.*

cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- $HOME/.gradle/caches/jars-1
- $HOME/.gradle/caches/jars-2
- $HOME/.gradle/caches/jars-3
- $HOME/.gradle/caches/modules-2/files-2.1/
- $HOME/.gradle/native
- $HOME/.gradle/wrapper

before_install:
- ./gradlew downloadDependencies
after_script:
- ./gradlew sendCoverageToCodacy

deploy:
provider: releases
api_key: ${GH_TOKEN}
file_glob: true
file:
- "build/libs/*.jar"
- "testing/build/libs/*.jar"
skip_cleanup: true
on:
tags: true

after_deploy:
- ./gradlew bintrayUpload
- provider: releases
api_key: ${GH_TOKEN}
file_glob: true
file:
- "build/libs/*.jar"
- "testing/build/libs/*.jar"
skip_cleanup: true
on:
tags: true
- provider: script
script: ./gradlew artifactoryPublish
skip_cleanup: true
on:
branch: dev
- provider: script
script: ./gradlew bintrayUpload
skip_cleanup: true
on:
tags: true
22 changes: 19 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.4'
compile group: 'org.radarcns', name: 'radar-commons', version: '0.4.1'
}
```

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

Expand All @@ -38,6 +38,22 @@ to send data to your backend.

## Contributing

For latest code use `dev` branch.
For latest code use `dev` branch. This is released on JFrog's OSS Artifactory. To use that release, add the following fragment to your `build.gradle` file.

```gradle
repositories {
maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local/' }
}
configurations.all {
// Check for updates every build
resolutionStrategy.cacheChangingModulesFor 0, 'SECONDS'
}
dependencies {
compile group: 'org.radarcns', name: 'radar-commons', version: '0.4.2-SNAPSHOT', changing: true
}
```

Code should be formatted using the [Google Java Code Style Guide](https://google.github.io/styleguide/javaguide.html).
If you want to contribute a feature or fix browse our [issues](https://github.com/RADAR-CNS/RADAR-Commons/issues), and please make a pull request.
31 changes: 27 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
plugins {
// Get bintray version
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 @@ -34,7 +37,7 @@ allprojects {
// Configuration //
//---------------------------------------------------------------------------//

version = '0.4'
version = '0.4.1'
group = 'org.radarcns'
ext.githubRepoName = 'RADAR-CNS/RADAR-Commons'

Expand All @@ -43,7 +46,7 @@ allprojects {
ext.avroVersion = '1.8.1'
ext.confluentVersion = '3.1.2'
ext.log4jVersion = '2.7'
ext.jacksonVersion='2.8.5'
ext.jacksonVersion = '2.8.5'
ext.okhttpVersion = '3.6.0'
ext.okioVersion = '1.11.0'
ext.junitVersion = '4.12'
Expand All @@ -69,8 +72,8 @@ allprojects {
ext.pomConfig = {
licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
Expand Down Expand Up @@ -334,6 +337,26 @@ bintray {
}
}

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('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) {
gradleVersion = '3.4.1'
distributionUrl distributionUrl.replace("bin", "all")
Expand Down
97 changes: 97 additions & 0 deletions src/main/java/org/radarcns/config/AvroTopicConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* Copyright 2017 The Hyve and King's College London
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.radarcns.config;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Objects;
import org.apache.avro.Schema;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.specific.SpecificRecord;
import org.radarcns.topic.AvroTopic;

/**
* Specifies an Avro topic
*/
public class AvroTopicConfig {
private String topic;
@JsonProperty("key_schema")
private String keySchema;
@JsonProperty("value_schema")
private String valueSchema;
private List<String> tags;

/**
* Parse an AvroTopic from the values in this class.
*/
@SuppressWarnings("unchecked")
public <K extends SpecificRecord, V extends SpecificRecord> AvroTopic<K, V> parseAvroTopic()
throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException,
IllegalAccessException {

Objects.requireNonNull(this.topic, "topic needs to be specified");
Objects.requireNonNull(this.keySchema, "key_schema needs to be specified");
Objects.requireNonNull(this.valueSchema, "value_schema needs to be specified");

Class<K> keyClass = (Class<K>) Class.forName(this.keySchema);
Schema keyAvroSchema = (Schema) keyClass
.getMethod("getClassSchema").invoke(null);
// check instantiation
SpecificData.newInstance(keyClass, keyAvroSchema);

Class<V> valueClass = (Class<V>) Class.forName(this.valueSchema);
Schema valueAvroSchema = (Schema) valueClass
.getMethod("getClassSchema").invoke(null);
// check instantiation
SpecificData.newInstance(valueClass, valueAvroSchema);

return new AvroTopic<>(topic, keyAvroSchema, valueAvroSchema, keyClass, valueClass);
}

public String getTopic() {
return topic;
}

public void setTopic(String topic) {
this.topic = topic;
}

public String getKeySchema() {
return keySchema;
}

public void setKeySchema(String keySchema) {
this.keySchema = keySchema;
}

public String getValueSchema() {
return valueSchema;
}

public void setValueSchema(String valueSchema) {
this.valueSchema = valueSchema;
}

public List<String> getTags() {
return tags;
}

public void setTags(List<String> tags) {
this.tags = tags;
}
}
1 change: 1 addition & 0 deletions src/main/java/org/radarcns/data/AvroRecordWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public AvroRecordWriter(EncoderFactory encoderFactory, Schema schema, DatumWrite
}
}

@Override
public byte[] encode(T record) throws IOException {
try {
writer.write(record, encoder);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/radarcns/data/SpecificRecordDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ private AvroRecordReader(Schema schema, DatumReader<T> reader) throws IOExceptio
this.decoder = null;
}

@Override
public T decode(byte[] record) throws IOException {
return decode(record, 0);
}

@Override
public T decode(byte[] record, int offset) throws IOException {
if (binary) {
decoder = decoderFactory.binaryDecoder(record, offset, record.length - offset,
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/org/radarcns/producer/AuthenticationException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2017 The Hyve and King's College London
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.radarcns.producer;

import java.io.IOException;

/**
* Failed to authenticate to server.
*/
public class AuthenticationException extends IOException {
public AuthenticationException() {
super();
}

public AuthenticationException(String message, Throwable cause) {
super(message, cause);
}

public AuthenticationException(String message) {
super(message);
}

public AuthenticationException(Throwable cause) {
super(cause);
}
}
13 changes: 13 additions & 0 deletions src/main/java/org/radarcns/producer/KafkaTopicSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ public interface KafkaTopicSender<K, V> extends Closeable {
/**
* Send a message to Kafka eventually. Given offset must be strictly monotonically increasing
* for subsequent calls.
*
* @param offset local offset, monotonically increasing
* @param key key of a kafka record to send
* @param value value of a kafka record to send
* @throws AuthenticationException if the client failed to authenticate itself
* @throws IOException if the client could not send a message
*/
void send(long offset, K key, V value) throws IOException;

Expand All @@ -34,6 +40,10 @@ public interface KafkaTopicSender<K, V> extends Closeable {
*
* Contained offsets must be strictly monotonically increasing
* for subsequent calls.
*
* @param records records to send.
* @throws AuthenticationException if the client failed to authenticate itself
* @throws IOException if the client could not send a message
*/
void send(List<Record<K, V>> records) throws IOException;

Expand All @@ -49,6 +59,9 @@ public interface KafkaTopicSender<K, V> extends Closeable {

/**
* Flush all remaining messages.
*
* @throws AuthenticationException if the client failed to authenticate itself
* @throws IOException if the client could not send a message
*/
void flush() throws IOException;
}
Loading

0 comments on commit a43961d

Please sign in to comment.