Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/java-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4
with:
distribution: 'temurin'
java-version: 17
java-version: 21
- name: Set up Maven
uses: stCarolas/setup-maven@d6af6abeda15e98926a57b5aa970a96bb37f97d1 # v5
with:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM registry.access.redhat.com/ubi8/openjdk-17@sha256:06edd8c82406da7466b73d589a07a10bf121ae5677b0f32e76120213d5303824 AS builder
FROM registry.access.redhat.com/ubi8/openjdk-21@sha256:a10b277c0f16283bb45b0e6cfca3ae9ecf155178f7f731df4a1f744ebd35af70 AS builder
USER 0
WORKDIR /work
COPY ./ .

RUN mvn -V -B package -pl build-request-processor -am -Dmaven.test.skip

FROM registry.access.redhat.com/ubi8/openjdk-17-runtime@sha256:8e863153659dba9ee288b97b7cdf7a83274dd78b26da1e5da6798d0bd45166e8
FROM registry.access.redhat.com/ubi8/openjdk-21-runtime@sha256:c1bf8370627eaed6711ea22915b476d4216517c35c8f8268c0d39ed983bceaff
USER 0
WORKDIR /work/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void visit(int version, int access, String name, String signature, String
super.visit(version - 1, access, name, signature, superName, interfaces);
}

}, List.of(new ExpectedChange(ChangeType.MODIFY, "version:61.0>60.0")));
}, List.of(new ExpectedChange(ChangeType.MODIFY, "version:65.0>64.0")));
}

@Test
Expand Down
4 changes: 2 additions & 2 deletions java-components/cache/src/main/docker/Dockerfile.all-in-one
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.access.redhat.com/ubi8/openjdk-17@sha256:06edd8c82406da7466b73d589a07a10bf121ae5677b0f32e76120213d5303824 AS builder
FROM registry.access.redhat.com/ubi8/openjdk-21@sha256:a10b277c0f16283bb45b0e6cfca3ae9ecf155178f7f731df4a1f744ebd35af70 AS builder
USER 0
WORKDIR /work
COPY ./ .
Expand All @@ -7,7 +7,7 @@ RUN mkdir -p /work/cache/target/classes

RUN mvn -V -B package -pl cache -am -Dmaven.test.skip

FROM registry.access.redhat.com/ubi8/openjdk-17-runtime@sha256:8e863153659dba9ee288b97b7cdf7a83274dd78b26da1e5da6798d0bd45166e8
FROM registry.access.redhat.com/ubi8/openjdk-21-runtime@sha256:c1bf8370627eaed6711ea22915b476d4216517c35c8f8268c0d39ed983bceaff
USER 0
WORKDIR /work/

Expand Down
4 changes: 2 additions & 2 deletions java-components/cli/src/main/docker/Dockerfile.all-in-one
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM registry.access.redhat.com/ubi8/openjdk-17@sha256:06edd8c82406da7466b73d589a07a10bf121ae5677b0f32e76120213d5303824 AS builder
FROM registry.access.redhat.com/ubi8/openjdk-21@sha256:a10b277c0f16283bb45b0e6cfca3ae9ecf155178f7f731df4a1f744ebd35af70 AS builder

WORKDIR /work
COPY ./ .

RUN mvn -V -B package -pl cli -am -DskipTests

FROM registry.access.redhat.com/ubi8/openjdk-17-runtime@sha256:8e863153659dba9ee288b97b7cdf7a83274dd78b26da1e5da6798d0bd45166e8
FROM registry.access.redhat.com/ubi8/openjdk-21-runtime@sha256:c1bf8370627eaed6711ea22915b476d4216517c35c8f8268c0d39ed983bceaff
WORKDIR /work/

COPY --from=builder /work/cli/target/quarkus-app/lib/ /deployments/lib/
Expand Down
4 changes: 4 additions & 0 deletions java-components/domain-proxy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM quay.io/redhat-appstudio/buildah:v1.35.4@sha256:3d3575bb7d0df64abcf1f22f06e82101a945d03317db1f3caac12814f796d01c
RUN dnf install -y iproute
COPY client/target/domain-proxy-client-999-SNAPSHOT-runner /app/domain-proxy-client-runner
COPY server/target/domain-proxy-server-999-SNAPSHOT-runner /app/domain-proxy-server-runner
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,19 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.github.redhat-appstudio.jvmbuild</groupId>
<artifactId>domainproxy-parent</artifactId>
<artifactId>domain-proxy-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>
<artifactId>domainproxy-client</artifactId>
<artifactId>domain-proxy-client</artifactId>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
<groupId>io.github.redhat-appstudio.jvmbuild</groupId>
<artifactId>domain-proxy-common</artifactId>
</dependency>
</dependencies>

Expand All @@ -37,7 +31,6 @@
<goals>
<goal>build</goal>
<goal>generate-code</goal>
<goal>generate-code-tests</goal>
</goals>
</execution>
</executions>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.redhat.hacbs.domainproxy.client;

import static com.redhat.hacbs.domainproxy.common.CommonIOUtil.createChannelToSocketWriter;
import static com.redhat.hacbs.domainproxy.common.CommonIOUtil.createSocketToChannelWriter;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnixDomainSocketAddress;
import java.nio.channels.SocketChannel;

import jakarta.annotation.PostConstruct;
import jakarta.inject.Inject;
import jakarta.inject.Singleton;

import org.eclipse.microprofile.config.inject.ConfigProperty;

import io.quarkus.logging.Log;
import io.quarkus.runtime.Quarkus;
import io.quarkus.runtime.Startup;

@Startup
@Singleton
public class DomainProxyClient {

@Inject
@ConfigProperty(name = "client-domain-socket")
String domainSocket;

@Inject
@ConfigProperty(name = "client-http-port")
int clientHttpPort;

@Inject
@ConfigProperty(name = "byte-buffer-size")
int byteBufferSize;

@PostConstruct
public void start() {
Log.info("Starting domain proxy client...");
new Thread(() -> {
try (final ServerSocket serverSocket = new ServerSocket(clientHttpPort)) {
while (true) {
final Socket socket = serverSocket.accept();
final UnixDomainSocketAddress address = UnixDomainSocketAddress.of(domainSocket);
final SocketChannel channel = SocketChannel.open(address);
// Write from socket to channel
Thread.startVirtualThread(createSocketToChannelWriter(byteBufferSize, socket, channel));
// Write from channel to socket
Thread.startVirtualThread(createChannelToSocketWriter(byteBufferSize, channel, socket));
}
} catch (final IOException e) {
Log.errorf(e, "Error initialising domain proxy client");
}
Quarkus.asyncExit();
}).start();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
client-domain-socket=${DOMAIN_SOCKET:/tmp/domainserver}
client-http-port=8080
byte-buffer-size=${BYTE_BUFFER_SIZE:1024}
18 changes: 18 additions & 0 deletions java-components/domain-proxy/common/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.github.redhat-appstudio.jvmbuild</groupId>
<artifactId>domain-proxy-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>
<artifactId>domain-proxy-common</artifactId>

<dependencies>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.redhat.hacbs.domainproxy.common;

import java.io.IOException;
import java.net.Socket;
import java.net.SocketException;
import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousCloseException;
import java.nio.channels.SocketChannel;

import org.jboss.logging.Logger;

public final class CommonIOUtil {

Check warning on line 12 in java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java

View check run for this annotation

Codecov / codecov/patch

java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java#L12

Added line #L12 was not covered by tests

private static final Logger LOG = Logger.getLogger(CommonIOUtil.class);

Check warning on line 14 in java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java

View check run for this annotation

Codecov / codecov/patch

java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java#L14

Added line #L14 was not covered by tests

public static Runnable createSocketToChannelWriter(final int byteBufferSize, final Socket socket,
final SocketChannel channel) {
// Write from socket to channel
return () -> {

Check warning on line 19 in java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java

View check run for this annotation

Codecov / codecov/patch

java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java#L19

Added line #L19 was not covered by tests
int r;
final byte[] buf = new byte[byteBufferSize];
int bytesWritten = 0;
LOG.info("Writing from socket to channel");

Check warning on line 23 in java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java

View check run for this annotation

Codecov / codecov/patch

java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java#L21-L23

Added lines #L21 - L23 were not covered by tests
try {
while ((r = socket.getInputStream().read(buf)) > 0) {
channel.write(ByteBuffer.wrap(buf, 0, r));
bytesWritten += r;

Check warning on line 27 in java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java

View check run for this annotation

Codecov / codecov/patch

java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java#L26-L27

Added lines #L26 - L27 were not covered by tests
}
} catch (final SocketException ignore) {
LOG.info("Socket closed");
} catch (final IOException e) {
LOG.errorf(e, "Error writing from socket to channel");

Check warning on line 32 in java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java

View check run for this annotation

Codecov / codecov/patch

java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java#L29-L32

Added lines #L29 - L32 were not covered by tests
} finally {
try {
channel.close();
} catch (final Exception e) {
LOG.errorf(e, "Error closing channel");
}

Check warning on line 38 in java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java

View check run for this annotation

Codecov / codecov/patch

java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java#L35-L38

Added lines #L35 - L38 were not covered by tests
try {
socket.close();
} catch (final IOException e) {
LOG.errorf(e, "Error closing socket");
}

Check warning on line 43 in java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java

View check run for this annotation

Codecov / codecov/patch

java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java#L40-L43

Added lines #L40 - L43 were not covered by tests
}
LOG.infof("Wrote %d bytes from socket to channel", bytesWritten);
};

Check warning on line 46 in java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java

View check run for this annotation

Codecov / codecov/patch

java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java#L45-L46

Added lines #L45 - L46 were not covered by tests
}

public static Runnable createChannelToSocketWriter(final int byteBufferSize, final SocketChannel channel,
final Socket socket) {
// Write from channel to socket
return () -> {

Check warning on line 52 in java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java

View check run for this annotation

Codecov / codecov/patch

java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java#L52

Added line #L52 was not covered by tests
int r;
final ByteBuffer buf = ByteBuffer.allocate(byteBufferSize);
buf.clear();
int bytesWritten = 0;
LOG.info("Writing from channel to socket");

Check warning on line 57 in java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java

View check run for this annotation

Codecov / codecov/patch

java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java#L54-L57

Added lines #L54 - L57 were not covered by tests
try {
while ((r = channel.read(buf)) > 0) {
buf.flip();
socket.getOutputStream().write(buf.array(), buf.arrayOffset(), buf.remaining());
buf.clear();
bytesWritten += r;

Check warning on line 63 in java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java

View check run for this annotation

Codecov / codecov/patch

java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java#L60-L63

Added lines #L60 - L63 were not covered by tests
}
} catch (final AsynchronousCloseException ignore) {
LOG.info("Channel closed");
} catch (final Exception e) {
LOG.errorf(e, "Error writing from channel to socket");

Check warning on line 68 in java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java

View check run for this annotation

Codecov / codecov/patch

java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java#L65-L68

Added lines #L65 - L68 were not covered by tests
} finally {
try {
channel.close();
} catch (final IOException e) {
LOG.errorf(e, "Error closing channel");
}

Check warning on line 74 in java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java

View check run for this annotation

Codecov / codecov/patch

java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java#L71-L74

Added lines #L71 - L74 were not covered by tests
try {
socket.close();
} catch (final IOException e) {
LOG.errorf(e, "Error closing socket");
}

Check warning on line 79 in java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java

View check run for this annotation

Codecov / codecov/patch

java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java#L76-L79

Added lines #L76 - L79 were not covered by tests
}
LOG.infof("Wrote %d bytes from channel to socket", bytesWritten);
};

Check warning on line 82 in java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java

View check run for this annotation

Codecov / codecov/patch

java-components/domain-proxy/common/src/main/java/com/redhat/hacbs/domainproxy/common/CommonIOUtil.java#L81-L82

Added lines #L81 - L82 were not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<artifactId>jvm-build-service-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>
<artifactId>domainproxy-parent</artifactId>
<artifactId>domain-proxy-parent</artifactId>
<packaging>pom</packaging>
<properties>
<skipITs>true</skipITs>
Expand All @@ -16,8 +16,19 @@
<modules>
<module>server</module>
<module>client</module>
<module>common</module>
</modules>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.github.redhat-appstudio.jvmbuild</groupId>
<artifactId>domain-proxy-common</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

<profiles>
<profile>
<id>native</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.github.redhat-appstudio.jvmbuild</groupId>
<artifactId>domainproxy-parent</artifactId>
<artifactId>domain-proxy-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>
<artifactId>domainproxy-server</artifactId>
<artifactId>domain-proxy-server</artifactId>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest</artifactId>
<artifactId>quarkus-vertx</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
Expand All @@ -28,9 +28,14 @@
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.github.redhat-appstudio.jvmbuild</groupId>
<artifactId>common-maven</artifactId>
<artifactId>domain-proxy-common</artifactId>
</dependency>
</dependencies>

Expand Down
Loading
Loading