Skip to content

add support for ARM based platforms #300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f38ab09
add support for ARM based platforms
muellerc Dec 30, 2021
5def05c
Merge branch 'master' into master
carlzogh Jan 5, 2022
20a4a77
incorporated pr feedback
muellerc Jan 6, 2022
c0197c6
fixed build-jni-lib.sh script after refactoring it
muellerc Jan 8, 2022
276981f
incorporated feedback from https://github.com/aws/aws-lambda-java-lib…
muellerc Jan 11, 2022
5a3c2fd
incorporated feedback from https://github.com/aws/aws-lambda-java-lib…
muellerc Jan 12, 2022
8c2bacc
incorporated feedback from https://github.com/aws/aws-lambda-java-lib…
muellerc Jan 12, 2022
213b619
incorporated feedback from https://github.com/aws/aws-lambda-java-lib…
muellerc Jan 12, 2022
a8357a0
add support for ARM based platforms
muellerc Dec 30, 2021
2413949
incorporated pr feedback
muellerc Jan 6, 2022
1d39500
fixed build-jni-lib.sh script after refactoring it
muellerc Jan 8, 2022
81112d9
incorporated feedback from https://github.com/aws/aws-lambda-java-lib…
muellerc Jan 11, 2022
fe7b9b2
incorporated feedback from https://github.com/aws/aws-lambda-java-lib…
muellerc Jan 12, 2022
b68425e
incorporated feedback from https://github.com/aws/aws-lambda-java-lib…
muellerc Jan 12, 2022
abdfdb3
incorporated feedback from https://github.com/aws/aws-lambda-java-lib…
muellerc Jan 12, 2022
386f50c
Merge branch 'master' of https://github.com/muellerc/aws-lambda-java-…
muellerc Jan 16, 2022
fd59cb3
upgrade jacoco maven plugin from 0.8.6 to 0.8.7 to solve a build erro…
muellerc Jan 16, 2022
b876b25
update Dockerfile agent to use Java 8 again
muellerc Jan 16, 2022
5f64ed1
Merge branch 'master' into master
carlzogh Jan 17, 2022
5972fc8
Update RELEASE.CHANGELOG.md
carlzogh Jan 17, 2022
82dbc9d
Update Dockerfile.agent
carlzogh Jan 17, 2022
9bc66d9
Update UnknownPlatformException.java
carlzogh Jan 17, 2022
20e29b6
Update java-core and maven-compiler-plugin, use CodeBuild image from ECR
carlzogh Jan 17, 2022
37c2c7f
Stage RIC 2.1.0, change to use Public ECR base image for amazoncorret…
carlzogh Jan 20, 2022
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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ ___
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-runtime-interface-client</artifactId>
<version>2.0.0</version>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
Expand All @@ -69,7 +69,7 @@ ___
'com.amazonaws:aws-lambda-java-events:3.11.0'
'com.amazonaws:aws-lambda-java-events-sdk-transformer:3.0.7'
'com.amazonaws:aws-lambda-java-log4j2:1.5.1'
'com.amazonaws:aws-lambda-java-runtime-interface-client:2.0.0'
'com.amazonaws:aws-lambda-java-runtime-interface-client:2.1.0'
'com.amazonaws:aws-lambda-java-tests:1.1.1'
```

Expand All @@ -80,7 +80,7 @@ ___
[com.amazonaws/aws-lambda-java-events "3.11.0"]
[com.amazonaws/aws-lambda-java-events-sdk-transformer "3.0.7"]
[com.amazonaws/aws-lambda-java-log4j2 "1.5.1"]
[com.amazonaws/aws-lambda-java-runtime-interface-client "2.0.0"]
[com.amazonaws/aws-lambda-java-runtime-interface-client "2.1.0"]
[com.amazonaws/aws-lambda-java-tests "1.1.1"]
```

Expand All @@ -91,7 +91,7 @@ ___
"com.amazonaws" % "aws-lambda-java-events" % "3.11.0"
"com.amazonaws" % "aws-lambda-java-events-sdk-transformer" % "3.0.7"
"com.amazonaws" % "aws-lambda-java-log4j2" % "1.5.1"
"com.amazonaws" % "aws-lambda-java-runtime-interface-client" % "2.0.0"
"com.amazonaws" % "aws-lambda-java-runtime-interface-client" % "2.1.0"
"com.amazonaws" % "aws-lambda-java-tests" % "1.1.1"
```

Expand Down
28 changes: 26 additions & 2 deletions aws-lambda-java-events/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<lombok.version>1.18.22</lombok.version>
</properties>

<distributionManagement>
Expand Down Expand Up @@ -72,7 +73,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.16</version>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -108,7 +109,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand Down Expand Up @@ -159,6 +160,29 @@
<autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Expand Down
4 changes: 2 additions & 2 deletions aws-lambda-java-runtime-interface-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ You can include this package in your preferred base image to make that base imag

Choose a preferred base image. The Runtime Interface Client is tested on Amazon Linux, Alpine, Ubuntu, Debian, and CentOS. The requirements are that the image is:

* built for x86_64
* built for x86_64 and ARM64
* contains Java >= 8
* contains glibc >= 2.17 or musl

Expand Down Expand Up @@ -70,7 +70,7 @@ pom.xml
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-runtime-interface-client</artifactId>
<version>2.0.0</version>
<version>2.1.0</version>
</dependency>
</dependencies>
<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### January 20, 2022
`2.1.0`
- fix: Added support for ARM64 architecture

### Sept 29, 2021
`2.0.0`
- Added support for ARM64 architecture
Expand All @@ -9,4 +13,4 @@

### December 01, 2020
`1.0.0`:
- Initial release of AWS Lambda Java Runtime Interface Client
- Initial release of AWS Lambda Java Runtime Interface Client
13 changes: 9 additions & 4 deletions aws-lambda-java-runtime-interface-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-runtime-interface-client</artifactId>
<version>2.0.0</version>
<version>2.1.0</version>
<packaging>jar</packaging>

<name>AWS Lambda Java Runtime Interface Client</name>
Expand All @@ -31,15 +31,18 @@
</developers>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<jacoco.maven.plugin.version>0.8.7</jacoco.maven.plugin.version>
</properties>

<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.2.0</version>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
Expand Down Expand Up @@ -102,9 +105,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<version>3.8.1</version>
<configuration>
<encoding>UTF-8</encoding>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
Expand All @@ -123,7 +128,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<version>${jacoco.maven.plugin.version}</version>
<executions>
<execution>
<id>default-prepare-agent</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,20 @@
*/
class NativeClient {
private static final String nativeLibPath = "/tmp/.aws-lambda-runtime-interface-client";
private static final String architecturePathSuffix = "/" + getArchIdentifier();
// Implementation based on AWS CRT, but adopted to support 64-bit architectures only (ref. https://github.com/awslabs/aws-crt-java/blob/0e9c3db8b07258b57c2503cfc47c787ccef10670/src/main/java/software/amazon/awssdk/crt/CRT.java#L106-L134)
private static final String supported_arm_architectures = "^(aarch64.*|arm64.*)$";
private static final String supported_x86_architectures = "^(x8664|amd64|ia32e|em64t|x64|x86_64)$";
private static final String[] libsToTry = {
"/aws-lambda-runtime-interface-client.glibc.so",
"/aws-lambda-runtime-interface-client.musl.so",
"aws-lambda-runtime-interface-client.glibc.so",
"aws-lambda-runtime-interface-client.musl.so",
};
private static final Throwable[] exceptions = new Throwable[libsToTry.length];
static {
boolean loaded = false;
for (int i = 0; !loaded && i < libsToTry.length; ++i) {
try (InputStream lib = NativeClient.class.getResourceAsStream(libsToTry[i])) {
try (InputStream lib = NativeClient.class.getResourceAsStream(
Paths.get(architecturePathSuffix, libsToTry[i]).toString())) {
Files.copy(lib, Paths.get(nativeLibPath), StandardCopyOption.REPLACE_EXISTING);
System.load(nativeLibPath);
loaded = true;
Expand All @@ -44,10 +49,25 @@ class NativeClient {
initializeClient(userAgent.getBytes());
}

/**
* @return a string describing the detected architecture the RIC is executing on
* @throws UnknownPlatformException
*/
static String getArchIdentifier() {
String arch = System.getProperty("os.arch");

if (arch.matches(supported_x86_architectures)) {
return "x86_64";
} else if (arch.matches(supported_arm_architectures)) {
return "arm64";
}

throw new UnknownPlatformException("architecture not supported: " + arch);
}

static native void initializeClient(byte[] userAgent);

static native InvocationRequest next();

static native void postInvocationResponse(byte[] requestId, byte[] response);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.amazonaws.services.lambda.runtime.api.client.runtimeapi;

/**
* Copyright (c) 2022 Amazon. All rights reserved.
*/
public class UnknownPlatformException extends RuntimeException {

public UnknownPlatformException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,25 @@ SRC_DIR=$(dirname "$0")
DST_DIR=${1}
CURL_VERSION=7.77.0

# compile the native library
docker build -f "${SRC_DIR}/Dockerfile.glibc" --build-arg CURL_VERSION=${CURL_VERSION} -t lambda-java-jni-lib-glibc "${SRC_DIR}"
docker run --rm --entrypoint /bin/cat lambda-java-jni-lib-glibc /src/aws-lambda-runtime-interface-client.so > "${DST_DIR}"/classes/aws-lambda-runtime-interface-client.glibc.so
# Not using associative arrays to maintain bash 3 compatibility with building on MacOS
# MacOS ships with bash 3 and associative arrays require bash 4+
# Declaring a map as an array with the column character as a separator :
declare -a ARCHITECTURES_TO_PLATFORM=(
"x86_64:linux/amd64"
"arm64:linux/arm64/v8"
)

docker build -f "${SRC_DIR}/Dockerfile.musl" --build-arg CURL_VERSION=${CURL_VERSION} -t lambda-java-jni-lib-musl "${SRC_DIR}"
docker run --rm --entrypoint /bin/cat lambda-java-jni-lib-musl /src/aws-lambda-runtime-interface-client.so > "${DST_DIR}"/classes/aws-lambda-runtime-interface-client.musl.so
declare -a TARGETS=("glibc" "musl")

for pair in "${ARCHITECTURES_TO_PLATFORM[@]}"; do
arch=${pair%%:*}
platform=${pair#*:}

mkdir -p "${DST_DIR}"/classes/"${arch}"

for target in "${TARGETS[@]}"; do
echo "Compiling the native library for target ${target} on architecture ${arch} using Docker platform ${platform}"
docker build --platform="${platform}" -f "${SRC_DIR}"/Dockerfile."${target}" --build-arg CURL_VERSION=${CURL_VERSION} -t lambda-java-jni-lib-"${target}"-"${arch}" "${SRC_DIR}"
docker run --rm --entrypoint /bin/cat lambda-java-jni-lib-"${target}"-"${arch}" /src/aws-lambda-runtime-interface-client.so > "${DST_DIR}"/classes/"${arch}"/aws-lambda-runtime-interface-client."${target}".so
done
done
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ else
docker_command+=" -e \"INITIATOR=$USER\""
fi

docker_command+=" amazon/aws-codebuild-local:latest"
docker_command+=" public.ecr.aws/codebuild/local-builds:latest"

# Note we do not expose the AWS_SECRET_ACCESS_KEY or the AWS_SESSION_TOKEN
exposed_command=$docker_command
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG RUNTIME_VERSION

FROM amazoncorretto:${RUNTIME_VERSION}
FROM public.ecr.aws/amazoncorretto/amazoncorretto:${RUNTIME_VERSION}

ADD aws-lambda-java-runtime-interface-client/test/integration/test-handler/target/HelloWorld-1.0.jar .

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-runtime-interface-client</artifactId>
<version>2.0.0</version>
<version>2.1.0</version>
</dependency>
</dependencies>

Expand Down
3 changes: 2 additions & 1 deletion aws-lambda-java-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>5.7.0</junit.version>
<jacoco.maven.plugin.version>0.8.7</jacoco.maven.plugin.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -127,7 +128,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<version>${jacoco.maven.plugin.version}</version>
<executions>
<execution>
<id>default-prepare-agent</id>
Expand Down