Skip to content

Commit f99b24f

Browse files
committed
Merge branch 'dev' into release-0.4.0
2 parents be4eaa1 + f1b5297 commit f99b24f

31 files changed

+151
-68
lines changed

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.git/
2+
build/
3+
src/test/
4+
out/
5+
.gradle/
6+
.idea/

Dockerfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License");
2+
# you may not use this file except in compliance with the License.
3+
# You may obtain a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS,
9+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
# See the License for the specific language governing permissions and
11+
# limitations under the License.
12+
13+
FROM openjdk:8-alpine AS builder
14+
15+
RUN mkdir /code
16+
WORKDIR /code
17+
18+
ENV GRADLE_OPTS -Dorg.gradle.daemon=false
19+
20+
COPY ./gradle /code/gradle
21+
COPY ./gradlew /code/
22+
RUN ./gradlew --version
23+
24+
COPY ./build.gradle ./gradle.properties ./settings.gradle /code/
25+
26+
RUN ./gradlew downloadDependencies copyDependencies startScripts
27+
28+
COPY ./src /code/src
29+
30+
RUN ./gradlew jar
31+
32+
FROM openjdk:8-jre-alpine
33+
34+
MAINTAINER Joris Borgdorff <[email protected]>
35+
36+
LABEL description="RADAR-base HDFS data restructuring"
37+
38+
COPY --from=builder /code/build/third-party/* /usr/lib/
39+
COPY --from=builder /code/build/scripts/* /usr/bin/
40+
COPY --from=builder /code/build/libs/* /usr/lib/
41+
42+
ENTRYPOINT ["radar-hdfs-restructure"]

README.md

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,59 @@
22

33
[![Build Status](https://travis-ci.org/RADAR-base/Restructure-HDFS-topic.svg?branch=master)](https://travis-ci.org/RADAR-base/Restructure-HDFS-topic)
44

5-
Data streamed to HDFS using the [RADAR HDFS sink connector](https://github.com/RADAR-base/RADAR-HDFS-Sink-Connector) is streamed to files based on sensor only. This package can transform that output to a local directory structure as follows: `userId/topic/date_hour.csv`. The date and hour is extracted from the `time` field of each record, and is formatted in UTC time.
5+
Data streamed to HDFS using the [RADAR HDFS sink connector](https://github.com/RADAR-CNS/RADAR-HDFS-Sink-Connector) is streamed to files based on sensor only. This package can transform that output to a local directory structure as follows: `userId/topic/date_hour.csv`. The date and hour is extracted from the `time` field of each record, and is formatted in UTC time. This package is included in the [RADAR-Docker](https://github.com/RADAR-CNS/RADAR-Docker) repository, in the `dcompose/radar-cp-hadoop-stack/hdfs_restructure.sh` script.
66

7-
## Usage
7+
## Docker usage
8+
9+
This package is available as docker image [`radarbase/radar-hdfs-restructure`](https://hub.docker.com/r/radarbase/radar-hdfs-restructure). The entrypoint of the image is the current application. So in all of the commands listed in usage, replace `radar-hdfs-restructure` with for example:
10+
```shell
11+
docker run --rm -t --network hadoop -v "$PWD/output:/output" radarbase/radar-hdfs-restructure:0.4.0 -u hdfs://hdfs -o /output /myTopic
12+
```
13+
if your docker cluster is running in the `hadoop` network and your output directory should be `./output`.
814

9-
This package is included in the [RADAR-Docker](https://github.com/RADAR-base/RADAR-Docker) repository, in the `dcompose/radar-cp-hadoop-stack/hdfs_restructure.sh` script.
1015

11-
## Advanced usage
16+
## Local build
1217

13-
Build jar from source with
18+
This package requires at least Java JDK 8. Build the distribution with
1419

1520
```shell
1621
./gradlew build
1722
```
18-
and find the output JAR file as `build/libs/restructurehdfs-0.4.0-all.jar`. Then run with:
23+
24+
and install the package into `/usr/local` with for example
25+
```shell
26+
sudo mkdir -p /usr/local
27+
sudo tar -xzf build/distributions/radar-hdfs-restructure-0.4.0.tar.gz -C /usr/local --strip-components=1
28+
```
29+
30+
Now the `radar-hdfs-restructure` command should be available.
31+
32+
## Command line usage
33+
34+
When the application is installed, it can be used as follows:
1935

2036
```shell
21-
java -jar restructurehdfs-0.4.0-all.jar --hdfs-uri <webhdfs_url> --output-directory <output_folder> <input_path_1> [<input_path_2> ...]
37+
radar-hdfs-restructure --hdfs-uri <webhdfs_url> --output-directory <output_folder> <input_path_1> [<input_path_2> ...]
2238
```
2339
or you can use the short form as well like -
2440
```shell
25-
java -jar restructurehdfs-0.4.0-all.jar -u <webhdfs_url> -o <output_folder> <input_path_1> [<input_path_2> ...]
41+
radar-hdfs-restructure -u <webhdfs_url> -o <output_folder> <input_path_1> [<input_path_2> ...]
2642
```
2743

2844
To display the usage and all available options you can use the help option as follows -
2945
```shell
30-
java -jar restructurehdfs-0.4.0-all.jar --help
46+
radar-hdfs-restructure --help
3147
```
3248
Note that the options preceded by the `*` in the above output are required to run the app. Also note that there can be multiple input paths from which to read the files. Eg - `/topicAndroidNew/topic1 /topicAndroidNew/topic2 ...`. At least one input path is required.
3349

3450
By default, this will output the data in CSV format. If JSON format is preferred, use the following instead:
3551
```shell
36-
java -jar restructurehdfs-0.4.0-all.jar --format json --hdfs-uri <webhdfs_url> --output-directory <output_folder> <input_path_1> [<input_path_2> ...]
52+
radar-hdfs-restructure --format json --hdfs-uri <webhdfs_url> --output-directory <output_folder> <input_path_1> [<input_path_2> ...]
3753
```
3854

3955
Another option is to output the data in compressed form. All files will get the `gz` suffix, and can be decompressed with a GZIP decoder. Note that for a very small number of records, this may actually increase the file size.
4056
```
41-
java -jar restructurehdfs-0.4.0-all.jar --compression gzip --hdfs-uri <webhdfs_url> --output-directory <output_folder> <input_path_1> [<input_path_2> ...]
57+
radar-hdfs-restructure --compression gzip --hdfs-uri <webhdfs_url> --output-directory <output_folder> <input_path_1> [<input_path_2> ...]
4258
```
4359

4460
By default, files records are not deduplicated after writing. To enable this behaviour, specify the option `--deduplicate` or `-d`. This set to false by default because of an issue with Biovotion data. Please see - [issue #16](https://github.com/RADAR-base/Restructure-HDFS-topic/issues/16) before enabling it.

build.gradle

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ group 'org.radarcns.restructurehdfs'
55
version '0.4.0'
66
mainClassName = 'org.radarcns.RestructureAvroRecords'
77

8-
run {
9-
args = ['webhdfs://localhost:50070', '/topicAndroidNew/android_phone_sensor_acceleration', "${projectDir}/data"]
10-
}
11-
128
sourceCompatibility = '1.8'
139
targetCompatibility = '1.8'
1410

@@ -37,26 +33,37 @@ dependencies {
3733
testImplementation group: 'junit', name: 'junit', version: '4.12'
3834
}
3935

40-
//create a single Jar with all dependencies
41-
task fatJar(type: Jar) {
36+
jar {
4237
manifest {
43-
attributes 'Implementation-Title': 'radar-restructure-hdfs',
44-
'Implementation-Version': version,
45-
'Main-Class': mainClassName
38+
attributes 'Implementation-Title': 'RADAR-base HDFS data restructuring',
39+
'Implementation-Version': version
4640
}
47-
classifier = 'all'
48-
from {
49-
configurations.runtimeClasspath.collect {
50-
it.isDirectory() ? it : zipTree(it)
41+
}
42+
43+
distributions {
44+
main {
45+
contents {
46+
into ("share/${project.name}") {
47+
from 'README.md', 'LICENSE'
48+
}
5149
}
52-
} {
53-
exclude 'META-INF/*'
5450
}
55-
with jar
5651
}
5752

58-
artifacts {
59-
archives fatJar
53+
tasks.withType(Tar){
54+
compression = Compression.GZIP
55+
extension = 'tar.gz'
56+
}
57+
58+
task downloadDependencies {
59+
description "Pre-downloads dependencies"
60+
configurations.compileClasspath.files
61+
configurations.runtimeClasspath.files
62+
}
63+
64+
task copyDependencies(type: Copy) {
65+
from configurations.runtimeClasspath.files
66+
into "${buildDir}/third-party/"
6067
}
6168

6269
wrapper {

gradle.properties

Whitespace-only changes.

settings.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
rootProject.name = 'restructurehdfs'
2-
1+
rootProject.name = 'radar-hdfs-restructure'

src/main/java/org/radarcns/Frequency.java renamed to src/main/java/org/radarcns/hdfs/Frequency.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.radarcns;
17+
package org.radarcns.hdfs;
1818

1919
import org.apache.commons.collections.MapIterator;
2020
import org.apache.commons.collections.keyvalue.MultiKey;

src/main/java/org/radarcns/OffsetRange.java renamed to src/main/java/org/radarcns/hdfs/OffsetRange.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.radarcns;
17+
package org.radarcns.hdfs;
1818

1919
import com.fasterxml.jackson.annotation.JsonCreator;
2020
import com.fasterxml.jackson.annotation.JsonProperty;

src/main/java/org/radarcns/OffsetRangeFile.java renamed to src/main/java/org/radarcns/hdfs/OffsetRangeFile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.radarcns;
17+
package org.radarcns.hdfs;
1818

1919
import com.fasterxml.jackson.databind.MappingIterator;
2020
import com.fasterxml.jackson.databind.ObjectReader;

src/main/java/org/radarcns/OffsetRangeSet.java renamed to src/main/java/org/radarcns/hdfs/OffsetRangeSet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.radarcns;
17+
package org.radarcns.hdfs;
1818

1919
import javax.annotation.Nonnull;
2020
import java.util.Iterator;

0 commit comments

Comments
 (0)