Skip to content
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

build: graalvm build #2717

Draft
wants to merge 1 commit into
base: postgresql-dialect
Choose a base branch
from
Draft
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
10 changes: 10 additions & 0 deletions build/native-image/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
mvn clean
mvn package -P assembly -DskipTests
cd target/pgadapter
native-image \
--shared \
--initialize-at-build-time=com.google.protobuf,com.google.gson \
-J-Xmx14g -H:IncludeResources=".*metadata.*json$" \
-H:ReflectionConfigurationFiles=../../build/native-image/reflectconfig.json \
-jar pgadapter.jar \
--no-fallback
19 changes: 19 additions & 0 deletions build/native-image/reflectconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[
{
"name" : "java.lang.Class",
"queryAllDeclaredConstructors" : true,
"queryAllPublicConstructors" : true,
"queryAllDeclaredMethods" : true,
"queryAllPublicMethods" : true,
"allDeclaredClasses" : true,
"allPublicClasses" : true
},
{
"name" : "java.time.Instant",
"methods" : [
{ "name" : "now" },
{ "name" : "getNano" },
{ "name" : "getEpochSecond" }
]
}
]
4 changes: 4 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>graal-sdk</artifactId>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-spanner</artifactId>
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/google/cloud/spanner/pgadapter/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
import org.graalvm.nativeimage.IsolateThread;
import org.graalvm.nativeimage.c.function.CEntryPoint;
import org.graalvm.nativeimage.c.type.CCharPointer;
import org.graalvm.nativeimage.c.type.CTypeConversion;

/** Effectively this is the main class */
public class Server {
Expand Down Expand Up @@ -85,6 +89,19 @@ public static void main(String[] args) {
}
}

@CEntryPoint(name = "start")
public static void start(IsolateThread thread, CCharPointer cArguments) {
String arguments = CTypeConversion.toJavaString(cArguments);
String[] args = arguments.split(" ");
try {
OptionsMetadata optionsMetadata = extractMetadata(args, System.out);
ProxyServer proxyServer = new ProxyServer(optionsMetadata, OpenTelemetry.noop());
proxyServer.startServer();
} catch (Exception e) {
printError(e, System.err, System.out);
}
}

/**
* Registers signal handlers for TERM, INT, and QUIT. This method uses reflection and fails
* gracefully if signal handling is not available on this JVM.
Expand Down
2 changes: 0 additions & 2 deletions wrappers/golang/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE=
golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/oauth2 v0.25.0 h1:CY4y7XT9v0cRI9oupztF8AgiIu99L/ksR/Xp/6jrZ70=
golang.org/x/oauth2 v0.25.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down
Loading