Skip to content

Commit b509fc6

Browse files
Add shadowJar plugin to examples.
1 parent 9c4cebb commit b509fc6

File tree

5 files changed

+89
-7
lines changed

5 files changed

+89
-7
lines changed

examples/map/README.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
11
# map examples
22

3-
## onheap
3+
## running examples
4+
5+
All examples have the gradle `shadowJar` plugin configured to easily run as a standalone app:
6+
7+
```
8+
cd examples/map/offheap
9+
java -jar build/libs/*shadowjar*.jar
10+
```
11+
12+
## onheap example
413

514
* Put 20,000 CacheObject instances into a ConcurrentHashMap.
615
* Each CacheObject instance contains a random string of length 500KB.
7-
* This is a total of 10 GB of data stored on the normal Java heap.
16+
* This is a total of 10GB of data stored on the normal Java heap.
817
* This application does not make use of any features of the native_memory_allocator library. It is provided for
918
comparison with NativeMemoryMap demos using off-heap storage.
19+
* As this application uses > 10GB of Java heap space, you may have to increase the Java heap size (e.g. `-Xmx20g`).
1020

11-
## offheap
21+
## offheap example
1222

1323
* Same as onheap but uses NativeMemoryMap with off-heap storage.
1424
* Uses the ConcurrentHashMap backend for NativeMemoryMap, which does not support eviction.
15-
* Total of 10 GB of data in off-heap memory.
25+
* Total of 10GB of data in off-heap memory.
1626

17-
## offheap-eviction
27+
## offheap-eviction example
1828

1929
* Same as offheap but uses the Caffeine backend with maximumSize of 10,000 entries.
20-
* Expect 10,000 entries at end of run with 10,000 total evictions.
30+
* Expect 10,000 map entries at end of run with 10,000 total evictions.
2131

22-
## offheap-eviction-operationcounters
32+
## offheap-eviction-operationcounters example
2333

2434
* Same as offheap-eviction but enables operation counters and logs them at the end of the demo.

examples/map/offheap-eviction-operationcounters/build.gradle.kts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2+
13
plugins {
24
kotlin("jvm")
5+
id("com.github.johnrengelman.shadow") version "7.1.2"
36
}
47

58
repositories {
@@ -8,4 +11,19 @@ repositories {
811

912
dependencies {
1013
implementation(project(":examples:map:utils"))
14+
}
15+
16+
tasks {
17+
named<ShadowJar>("shadowJar") {
18+
archiveBaseName.set("offheap-eviction-operationcounters-shadowjar")
19+
manifest {
20+
attributes(mapOf("Main-Class" to "com.target.nativememoryallocator.examples.map.offheap.eviction.operationcounters.OffHeapEvictionOperationCountersKt"))
21+
}
22+
}
23+
}
24+
25+
tasks {
26+
build {
27+
dependsOn(shadowJar)
28+
}
1129
}

examples/map/offheap-eviction/build.gradle.kts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2+
13
plugins {
24
kotlin("jvm")
5+
id("com.github.johnrengelman.shadow") version "7.1.2"
36
}
47

58
repositories {
@@ -8,4 +11,19 @@ repositories {
811

912
dependencies {
1013
implementation(project(":examples:map:utils"))
14+
}
15+
16+
tasks {
17+
named<ShadowJar>("shadowJar") {
18+
archiveBaseName.set("offheap-eviction-shadowjar")
19+
manifest {
20+
attributes(mapOf("Main-Class" to "com.target.nativememoryallocator.examples.map.offheap.eviction.OffHeapEvictionKt"))
21+
}
22+
}
23+
}
24+
25+
tasks {
26+
build {
27+
dependsOn(shadowJar)
28+
}
1129
}

examples/map/offheap/build.gradle.kts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2+
13
plugins {
24
kotlin("jvm")
5+
id("com.github.johnrengelman.shadow") version "7.1.2"
36
}
47

58
repositories {
@@ -8,4 +11,19 @@ repositories {
811

912
dependencies {
1013
implementation(project(":examples:map:utils"))
14+
}
15+
16+
tasks {
17+
named<ShadowJar>("shadowJar") {
18+
archiveBaseName.set("offheap-shadowjar")
19+
manifest {
20+
attributes(mapOf("Main-Class" to "com.target.nativememoryallocator.examples.map.offheap.OffHeapKt"))
21+
}
22+
}
23+
}
24+
25+
tasks {
26+
build {
27+
dependsOn(shadowJar)
28+
}
1129
}

examples/map/onheap/build.gradle.kts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2+
13
plugins {
24
kotlin("jvm")
5+
id("com.github.johnrengelman.shadow") version "7.1.2"
36
}
47

58
repositories {
@@ -8,4 +11,19 @@ repositories {
811

912
dependencies {
1013
implementation(project(":examples:map:utils"))
14+
}
15+
16+
tasks {
17+
named<ShadowJar>("shadowJar") {
18+
archiveBaseName.set("onheap-shadowjar")
19+
manifest {
20+
attributes(mapOf("Main-Class" to "com.target.nativememoryallocator.examples.map.onheap.OnHeapKt"))
21+
}
22+
}
23+
}
24+
25+
tasks {
26+
build {
27+
dependsOn(shadowJar)
28+
}
1129
}

0 commit comments

Comments
 (0)