Skip to content

Commit d18118f

Browse files
committed
Docker affinity test harness
1 parent 82dc0bb commit d18118f

File tree

6 files changed

+59
-9
lines changed

6 files changed

+59
-9
lines changed

Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM openjdk:17
2+
3+
COPY ./affinity/target/affinity-3.21ea84-SNAPSHOT-jar-with-dependencies.jar /app/
4+
COPY ./affinity/run.sh /app/
5+
WORKDIR /app
6+
ENTRYPOINT ["./run.sh"]

affinity/pom.xml

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
~ limitations under the License.
1616
-->
1717

18-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
18+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1920
<modelVersion>4.0.0</modelVersion>
2021

2122
<parent>
2223
<groupId>net.openhft</groupId>
2324
<artifactId>java-parent-pom</artifactId>
2425
<version>1.1.29</version>
25-
<relativePath />
26+
<relativePath/>
2627
</parent>
2728

2829
<artifactId>affinity</artifactId>
@@ -73,6 +74,10 @@
7374
<groupId>org.jetbrains</groupId>
7475
<artifactId>annotations</artifactId>
7576
</dependency>
77+
<dependency>
78+
<groupId>org.slf4j</groupId>
79+
<artifactId>slf4j-simple</artifactId>
80+
</dependency>
7681

7782
<dependency>
7883
<groupId>org.easymock</groupId>
@@ -84,11 +89,6 @@
8489
<artifactId>junit</artifactId>
8590
<scope>test</scope>
8691
</dependency>
87-
<dependency>
88-
<groupId>org.slf4j</groupId>
89-
<artifactId>slf4j-simple</artifactId>
90-
<scope>test</scope>
91-
</dependency>
9292
<dependency>
9393
<groupId>net.openhft</groupId>
9494
<artifactId>chronicle-test-framework</artifactId>
@@ -250,7 +250,28 @@
250250
</execution>
251251
</executions>
252252
</plugin>
253+
<plugin>
254+
<groupId>org.apache.maven.plugins</groupId>
255+
<artifactId>maven-assembly-plugin</artifactId>
256+
<version>3.3.0</version>
257+
258+
<executions>
259+
<execution>
260+
<id>make-uber-jar</id>
261+
<phase>package</phase>
262+
<goals>
263+
<goal>single</goal>
264+
</goals>
265+
<configuration>
266+
<descriptorRefs>
267+
<descriptorRef>jar-with-dependencies</descriptorRef>
268+
</descriptorRefs>
269+
</configuration>
270+
</execution>
271+
</executions>
272+
</plugin>
253273
</plugins>
274+
254275
</build>
255276

256277
<!-- todo remove once next parent pom is adopted -->

affinity/run.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
java -cp affinity-3.21ea84-SNAPSHOT-jar-with-dependencies.jar net.openhft.affinity.test.BindingTest $@
3+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package net.openhft.affinity.test;
2+
3+
import net.openhft.affinity.AffinityLock;
4+
5+
public class BindingTest {
6+
7+
public static void main(String[] args) {
8+
String cpuToBindTo = args.length > 0 ? args[0] : "last";
9+
System.out.println("Binding to " + cpuToBindTo);
10+
try (AffinityLock affinityLock = AffinityLock.acquireLock(cpuToBindTo)) {
11+
while (!Thread.currentThread().isInterrupted()) {
12+
// Do nothing, just busy wait
13+
}
14+
}
15+
}
16+
}

pom.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
~ limitations under the License.
1616
-->
1717

18-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
18+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1920
<modelVersion>4.0.0</modelVersion>
2021

2122
<parent>
2223
<groupId>net.openhft</groupId>
2324
<artifactId>root-parent-pom</artifactId>
2425
<version>1.2.13</version>
25-
<relativePath />
26+
<relativePath/>
2627
</parent>
2728

2829
<artifactId>Java-Thread-Affinity</artifactId>

run-experiment.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
docker build -t affinity-ex .
3+
docker run -it --rm --cpuset-cpus=2,3 affinity-ex last

0 commit comments

Comments
 (0)