Skip to content

Commit 850e9b2

Browse files
authored
Merge pull request #86 from RADAR-base/phaseOutHdfs
Phase out hdfs
2 parents cb5122b + 3c75022 commit 850e9b2

File tree

10 files changed

+71
-88
lines changed

10 files changed

+71
-88
lines changed

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,18 @@ MAINTAINER Joris Borgdorff <[email protected]>, Yatharth Ranjan<yatharth.ranjan@k
3131

3232
LABEL description="RADAR-base output data restructuring"
3333

34+
ENV RADAR_OUTPUT_RESTRUCTURE_OPTS=""
3435
ENV JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom -XX:+UseG1GC -XX:MaxHeapFreeRatio=10 -XX:MinHeapFreeRatio=10"
3536

3637
COPY --from=builder /code/build/third-party/* /usr/lib/
3738
COPY --from=builder /code/build/scripts/* /usr/bin/
3839
COPY --from=builder /code/build/libs/* /usr/lib/
3940

41+
RUN mkdir /output \
42+
&& chown 101:101 /output
43+
44+
VOLUME ["/output"]
45+
46+
USER 101:101
47+
4048
ENTRYPOINT ["radar-output-restructure"]

Dockerfile.hdfs

Lines changed: 0 additions & 47 deletions
This file was deleted.

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ It supports data written by [RADAR HDFS sink connector](https://github.com/RADAR
77

88
## Upgrade instructions
99

10+
When upgrading to version 1.2.0, please follow the following instructions:
11+
12+
- When using local target storage, ensure that:
13+
1. it is writable by the user 101, or change the runtime user using the docker command-line flag `--user` to a user that can write to the target storage and
14+
2. local storage properties `userId` and `groupId` are set to values that can write to the target storage.
15+
1016
When upgrading to version 1.0.0 or later from version 0.6.0 please follow the following instructions:
1117

1218
- This package now relies on Redis for locking and offset management. Please install Redis or use
@@ -36,9 +42,11 @@ When upgrading to version 1.0.0 or later from version 0.6.0 please follow the fo
3642
target:
3743
type: local
3844
local:
39-
# User ID to write data as
45+
# User ID to write data as. This only works when explicitly setting
46+
# the runtime user to root.
4047
userId: 123
41-
# Group ID to write data as
48+
# Group ID to write data as. This only works when explicitly setting
49+
# the runtime user to root.
4250
groupId: 123
4351
```
4452

@@ -60,12 +68,10 @@ When upgrading to version 0.6.0 from version 0.5.x or earlier, please follow the
6068
## Docker usage
6169

6270
This package is available as docker image [`radarbase/radar-output-restructure`](https://hub.docker.com/r/radarbase/radar-output-restructure). The entrypoint of the image is the current application. So in all the commands listed in usage, replace `radar-output-restructure` with for example:
71+
6372
```shell
64-
docker run --rm -t --network hadoop -v "$PWD/output:/output" radarbase/radar-output-restructure:1.1.5-hdfs -n hdfs-namenode -o /output /myTopic
73+
docker run --rm -t --network hadoop -v "$PWD/output:/output" radarbase/radar-output-restructure:1.1.5 -n hdfs-namenode -o /output /myTopic
6574
```
66-
if your docker cluster is running in the `hadoop` network and your output directory should be `./output`.
67-
68-
Docker image tags that are optimized for HDFS are suffixed with `-hdfs`. Otherwise, please use the image without that suffix.
6975

7076
## Command line usage
7177

build.gradle

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
plugins {
2-
id 'java'
3-
id 'java-library'
2+
id 'org.jetbrains.kotlin.jvm'
43
id 'application'
54
id 'com.jfrog.bintray' version '1.8.5'
65
id 'maven-publish'
7-
id 'org.jetbrains.kotlin.jvm'
6+
id "org.jetbrains.dokka"
87
id 'com.avast.gradle.docker-compose' version "0.13.4"
98
}
109

1110
group 'org.radarbase'
12-
version '1.1.6-SNAPSHOT'
11+
version '1.2.0-SNAPSHOT'
1312
mainClassName = 'org.radarbase.output.Application'
1413

15-
sourceCompatibility = '1.8'
16-
targetCompatibility = '1.8'
17-
1814
ext {
1915
moduleDescription = 'RADAR-base output restructuring'
2016
website = 'https://radar-base.org'
@@ -80,21 +76,15 @@ dependencies {
8076
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: junitVersion
8177
testImplementation group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3'
8278
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
83-
}
8479

85-
compileKotlin {
86-
kotlinOptions {
87-
jvmTarget = "1.8"
88-
}
80+
dokkaHtmlPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:$kotlinVersion")
8981
}
90-
compileTestKotlin {
91-
kotlinOptions {
92-
jvmTarget = "1.8"
93-
}
94-
}
95-
compileIntegrationTestKotlin {
82+
83+
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
9684
kotlinOptions {
97-
jvmTarget = "1.8"
85+
jvmTarget = "11"
86+
apiVersion = "1.4"
87+
languageVersion = "1.4"
9888
}
9989
}
10090

@@ -186,18 +176,17 @@ task sourcesJar(type: Jar, dependsOn: classes) {
186176
manifest.from sharedManifest
187177
}
188178

189-
task javadocJar(type: Jar, dependsOn: javadoc) {
190-
archiveClassifier.set('javadoc')
191-
from javadoc.destinationDir
192-
manifest.from sharedManifest
179+
task dokkaJar(type: Jar, dependsOn: dokkaJavadoc) {
180+
archiveClassifier.set("javadoc")
181+
from("$buildDir/dokka/javadoc/")
193182
}
194183

195184
publishing {
196185
publications {
197186
mavenJar(MavenPublication) {
198187
from components.java
199188
artifact sourcesJar
200-
artifact javadocJar
189+
artifact dokkaJar
201190
pom {
202191
url = githubUrl as String
203192
description = moduleDescription

restructure.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ target:
5858
container: MyTargetContainer
5959
# only actually needed if target type is local
6060
local:
61-
userId: 1000 # write as regular user, use -1 to use current user (default).
62-
groupId: 100 # write as regular group, use -1 to use current user (default).
61+
userId: 1000 # write as user ID 1000, use -1 to use current user (default).
62+
groupId: 100 # write as group ID 100, use -1 to use current user (default).
6363

6464
# Redis configuration
6565
# @since: 0.7.0

settings.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ pluginManagement {
22
resolutionStrategy {
33
eachPlugin {
44
if ( requested.id.id == 'org.jetbrains.kotlin.jvm' ) {
5-
useModule( "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" )
5+
useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
6+
}
7+
if (requested.id.id == "org.jetbrains.dokka") {
8+
useModule("org.jetbrains.dokka:dokka-gradle-plugin:$kotlinVersion")
69
}
710
}
811
}

src/main/java/org/radarbase/output/Application.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class Application(
198198
logger.error("Failed to initialize plugins", ex)
199199
exitProcess(1)
200200
} catch (e: IllegalStateException) {
201-
logger.error("Cannot process configuration", e)
201+
logger.error("Invalid configuration: {}", e.message)
202202
exitProcess(1)
203203
}
204204

src/main/java/org/radarbase/output/config/RestructureConfig.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ data class RestructureConfig(
3131
/** Topic exceptional handling. */
3232
val topics: Map<String, TopicConfig> = emptyMap(),
3333
/** Source data resource configuration. */
34-
val source: ResourceConfig = ResourceConfig("hdfs", hdfs = HdfsConfig()),
34+
val source: ResourceConfig = ResourceConfig("s3"),
3535
/** Target data resource configration. */
3636
val target: ResourceConfig = ResourceConfig("local", local = LocalConfig()),
3737
/** Redis configuration for synchronization and storing offsets. */
@@ -284,10 +284,10 @@ data class ResourceConfig(
284284
sourceType = type.toResourceType()
285285

286286
when(sourceType) {
287-
ResourceType.S3 -> checkNotNull(s3)
288-
ResourceType.HDFS -> checkNotNull(hdfs).also { it.validate() }
289-
ResourceType.LOCAL -> checkNotNull(local)
290-
ResourceType.AZURE -> checkNotNull(azure)
287+
ResourceType.S3 -> checkNotNull(s3) { "No S3 configuration provided." }
288+
ResourceType.HDFS -> checkNotNull(hdfs) { "No HDFS configuration provided." }.also { it.validate() }
289+
ResourceType.LOCAL -> checkNotNull(local) { "No local configuration provided." }
290+
ResourceType.AZURE -> checkNotNull(azure) { "No Azure configuration provided." }
291291
}
292292
}
293293
}
@@ -301,7 +301,7 @@ fun String.toResourceType() = when(toLowerCase()) {
301301
"hdfs" -> ResourceType.HDFS
302302
"local" -> ResourceType.LOCAL
303303
"azure" -> ResourceType.AZURE
304-
else -> throw IllegalArgumentException("Unknown resource type $this, choose s3, hdfs or local")
304+
else -> throw IllegalStateException("Unknown resource type $this, choose s3, hdfs or local")
305305
}
306306

307307
data class LocalConfig(

src/main/java/org/radarbase/output/target/TargetStorageFactory.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ class TargetStorageFactory(private val config: ResourceConfig) {
88
ResourceType.S3 -> S3TargetStorage(config.s3!!)
99
ResourceType.LOCAL -> LocalTargetStorage(config.local!!)
1010
ResourceType.AZURE -> AzureTargetStorage(config.azure!!)
11-
else -> throw IllegalArgumentException("Cannot create storage driver for ${config.sourceType}")
11+
else -> throw IllegalStateException("Cannot create storage driver for ${config.sourceType}")
1212
}
1313
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.radarbase.output.util
2+
3+
import org.hamcrest.MatcherAssert.assertThat
4+
import org.hamcrest.Matchers.`is`
5+
import org.junit.jupiter.api.Test
6+
import org.junit.jupiter.api.io.TempDir
7+
import java.nio.file.Files
8+
import java.nio.file.Path
9+
10+
internal class TemporaryDirectoryTest {
11+
@Test
12+
fun createAndDelete(@TempDir root: Path) {
13+
TemporaryDirectory(root, "worker-").use {
14+
assertThat(Files.list(root).count(), `is`(1L))
15+
Files.createTempFile(it.path, "test", "txt")
16+
Files.createTempFile(it.path, "test", "txt")
17+
18+
assertThat(Files.list(it.path).count(), `is`(2L))
19+
assertThat(Files.list(root).count(), `is`(1L))
20+
}
21+
22+
assertThat(Files.list(root).count(), `is`(0L))
23+
}
24+
}

0 commit comments

Comments
 (0)