Skip to content
This repository has been archived by the owner on Mar 16, 2022. It is now read-only.

Diagnosed remaining assembly errors #291

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
69 changes: 60 additions & 9 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@ name := "cloudstate"

val GrpcJavaVersion = "1.22.1"
val GraalAkkaVersion = "0.5.0"
val AkkaVersion = "2.5.31"
val AkkaVersion = "2.6.4"
val AkkaHttpVersion = "10.1.11"
// Can be removed when a post-0.8.4 version comes in (e.g. via akka-persistence-spanner)
val AkkaGrpcVersion = "0.8.4+25-52f006d6"
val AkkaManagementVersion = "1.0.5"
val AkkaPersistenceCassandraVersion = "0.102"
// https://github.com/akka/akka-persistence-spanner/pull/74
val AkkaPersistenceSpannerVersion = "0.1+14-bd4114ba"
val PrometheusClientVersion = "0.6.0"
val ScalaTestVersion = "3.0.5"
val ProtobufVersion = "3.9.0"
Expand Down Expand Up @@ -96,6 +100,7 @@ lazy val root = (project in file("."))
.aggregate(
`protocols`,
`proxy-core`,
`proxy-spanner`,
`proxy-cassandra`,
`proxy-postgres`,
`proxy-tests`,
Expand Down Expand Up @@ -270,15 +275,17 @@ commands ++= Seq(
buildProxyCommand("InMemory", `proxy-core`, "in-memory", Some("in-memory.conf"), false),
buildProxyCommand("Cassandra", `proxy-cassandra`, "cassandra", None, true),
buildProxyCommand("Cassandra", `proxy-cassandra`, "cassandra", None, false),
buildProxyCommand("Spanner", `proxy-spanner`, "spanner", None, true),
buildProxyCommand("Spanner", `proxy-spanner`, "spanner", None, false),
buildProxyCommand("Postgres", `proxy-postgres`, "postgres", None, true),
buildProxyCommand("Postgres", `proxy-postgres`, "postgres", None, false),
Command.single("dockerBuildAllNonNative", buildProxyHelp("dockerBuildAllNonNative", "all non native")) {
(state, command) =>
List("DevMode", "NoStore", "InMemory", "Cassandra", "Postgres")
List("DevMode", "NoStore", "InMemory", "Cassandra", "Postgres", "Spanner")
.map(c => s"dockerBuild$c $command") ::: state
},
Command.single("dockerBuildAllNative", buildProxyHelp("dockerBuildAllNative", "all native")) { (state, command) =>
List("DevMode", "NoStore", "InMemory", "Cassandra", "Postgres")
List("DevMode", "NoStore", "InMemory", "Cassandra", "Postgres", "Spanner")
.map(c => s"dockerBuildNative$c $command") ::: state
}
)
Expand Down Expand Up @@ -444,24 +451,68 @@ lazy val `proxy-core` = (project in file("proxy/core"))
nativeImageDockerSettings
)

lazy val `proxy-spanner` = (project in file("proxy/spanner"))
.enablePlugins(DockerPlugin, JavaAgent, GraalVMPlugin)
.dependsOn(`proxy-core`)
.settings(
common,
name := "cloudstate-proxy-spanner",
libraryDependencies ++= Seq(
"com.lightbend.akka" %% "akka-persistence-spanner" % AkkaPersistenceSpannerVersion,
// Can be removed when a post-0.8.4 version comes in (e.g. via akka-persistence-spanner)
"com.lightbend.akka.grpc" %% "akka-grpc-runtime" % AkkaGrpcVersion,
),
fork in run := true,
mainClass in Compile := Some("io.cloudstate.proxy.CloudstateSpannerProxyMain"),
mainClass in assembly := (mainClass in Compile).value,
assemblyJarName in assembly := "akka-proxy-spanner.jar",
test in assembly := {},
// logLevel in assembly := Level.Debug,
assemblyMergeStrategy in assembly := {
/*ADD CUSTOMIZATIONS HERE*/
case PathList("META-INF", "io.netty.versions.properties") => MergeStrategy.last
case "module-info.class" => MergeStrategy.discard
// Perhaps can be removed later depending on how
// https://github.com/akka/akka-persistence-spanner/issues/75
// is resolved
case "GoogleInternetAuthorityG3.crt" => MergeStrategy.first
// These are the only 2 .proto with this problem because the version in
// cloudstate has deviated from the upstream one since
// https://github.com/cloudstateio/cloudstate/pull/127
// We should still not ship these .proto's in akka-persistence-spanner, though
case "google/api/http.proto" => MergeStrategy.first
case "google/api/annotations.proto" => MergeStrategy.first
// This one is different in akka-protobuf-v3.
// We should still not ship these .proto's in akka-persistence-spanner
// and not in akka-protobuf-v3, though.
case "google/protobuf/field_mask.proto" => MergeStrategy.first
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can safely discard all ".proto"-files since the fat jar will not have them used for anything, it's only intended to be executed via java -jar

case x =>
val oldStrategy = (assemblyMergeStrategy in assembly).value
oldStrategy(x)
},
nativeImageDockerSettings,
graalVMNativeImageOptions ++= Seq(
)
)

lazy val `proxy-cassandra` = (project in file("proxy/cassandra"))
.enablePlugins(DockerPlugin, JavaAgent, GraalVMPlugin)
.dependsOn(`proxy-core`)
.settings(
common,
name := "cloudstate-proxy-cassandra",
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-persistence-cassandra" % AkkaPersistenceCassandraVersion excludeAll (
(excludeTheseDependencies :+ ExclusionRule("com.github.jnr")): _* // Can't native-image this, so we don't need this either
"com.typesafe.akka" %% "akka-persistence-cassandra" % AkkaPersistenceCassandraVersion excludeAll (
(excludeTheseDependencies :+ ExclusionRule("com.github.jnr")): _* // Can't native-image this, so we don't need this either
),
"com.typesafe.akka" %% "akka-persistence-cassandra-launcher" % AkkaPersistenceCassandraVersion % Test
),
"com.typesafe.akka" %% "akka-persistence-cassandra-launcher" % AkkaPersistenceCassandraVersion % Test
),
fork in run := true,
mainClass in Compile := Some("io.cloudstate.proxy.CloudStateProxyMain"),
nativeImageDockerSettings,
graalVMNativeImageOptions ++= Seq(
"-H:IncludeResourceBundles=com.datastax.driver.core.Driver"
)
"-H:IncludeResourceBundles=com.datastax.driver.core.Driver"
)
)

lazy val `proxy-jdbc` = (project in file("proxy/jdbc"))
Expand Down
52 changes: 52 additions & 0 deletions proxy/jdbc/src/main/resources/application.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//cloudstate.proxy.postgres {
// service = "localhost"
// service = ${?POSTGRES_SERVICE}
//
// port = 5432
// port = ${?POSTGRES_PORT}
//
// // Currently this is ignored
// schema = ${?POSTGRES_SCHEMA}
//
// database = "cloudstate"
// database = ${?POSTGRES_DATABASE}
//
// user = "cloudstate"
// user = ${?POSTGRES_USERNAME}
//
// password = "cloudstate"
// password = ${?POSTGRES_PASSWORD}
//}

akka {

grpc {
client.spanner-client {
host = "localhost"
port = 9010
use-tls = false
}
}

persistence {
journal {
plugin = "akka.persistence.spanner.journal"
}

snapshot-store {
plugin = "akka.persistence.snapshot-store.local"
}

spanner {
project = "spanner-test"
instance = "test-instance"
database = "test-database"

session-pool {
# emulator only supports a single transaction at a time
max-size = 1
}
use-auth = false
}
}
}
2 changes: 1 addition & 1 deletion proxy/postgres/src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ akka-persistence-jdbc.shared-databases.slick {
user = ${cloudstate.proxy.postgres.user}
password = ${cloudstate.proxy.postgres.password}
}
}
}
2 changes: 2 additions & 0 deletions proxy/spanner/src/graal/jni-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[
]
2 changes: 2 additions & 0 deletions proxy/spanner/src/graal/proxy-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[
]
2 changes: 2 additions & 0 deletions proxy/spanner/src/graal/reflect-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[
]
14 changes: 14 additions & 0 deletions proxy/spanner/src/graal/resource-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"resources":[
{"pattern":"META-INF/MANIFEST.MF"},
{"pattern":"META-INF/services/io.grpc.LoadBalancerProvider"},
{"pattern":"META-INF/services/io.grpc.NameResolverProvider"},
{"pattern":"akka-http-version.conf"},
{"pattern":"application.conf"},
{"pattern":"cloudstate-common.conf"},
{"pattern":"org/slf4j/impl/StaticLoggerBinder.class"},
{"pattern":"reference.conf"},
{"pattern":"simplelogger.properties"},
{"pattern":"version.conf"}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.cloudstate.proxy.spanner

import io.cloudstate.proxy.CloudStateProxyMain

object CloudstateSpannerProxyMain {

def main(args: Array[String]): Unit = {
val actorSystem = CloudStateProxyMain.start()
}
}
118 changes: 3 additions & 115 deletions tck/src/it/resources/application.conf
Original file line number Diff line number Diff line change
@@ -1,39 +1,4 @@
cloudstate-tck.combinations = [{
name = "Akka + Node.js"
tck {
hostname = "0.0.0.0"
port = 8090
}
proxy {
hostname = "127.0.0.1"
port = 9000
directory = ${user.dir}
command = ["java","-Xmx512M", "-Xms128M", "-Dconfig.resource=in-memory.conf", "-Dcloudstate.proxy.dev-mode-enabled=true", "-jar", "proxy/core/target/scala-2.12/akka-proxy.jar"]
// Switch to this if you want to use the tck to generate GraalVM Assisted Configuration generation when running the TCK
// command = [""${GRAALVM_HOME}"/bin/java", "-agentlib:native-image-agent=config-output-dir="${user.dir}"/proxy/core/graal","-Xmx512M", "-Xms128M", "-Dconfig.resource=in-memory.conf", "-Dcloudstate.proxy.dev-mode-enabled=true", "-jar", "proxy/core/target/scala-2.12/akka-proxy.jar"]
// Switch to this to run the TCK with the Graal native image in a docker container.
//command = ["docker", "run", "--rm", "--name", "cloudstate-proxy-tck", "-p", "9000:9000", "cloudstate-proxy-dev-mode",
// "-Dcloudstate.proxy.user-function-port=8090", "-Dcloudstate.proxy.user-function-interface=%LOCALHOST%"]
//stop-command = ["docker", "stop", "cloudstate-proxy-tck"]
// Switch to this to run the TCK with a native image that has been built for the local platform.
// Make sure that the ENV JAVA_LIBRARY_PATH is set to the /lib dir of the JRE to load libraries from
//command = ["proxy/core/target/graalvm-native-image/cloudstate-proxy-core", "-Djava.library.path="${JAVA_LIBRARY_PATH}]

env-vars {
USER_FUNCTION_PORT = "8090"
}
}

frontend {
hostname = "127.0.0.1"
port = 8080
directory = ${user.dir}/samples/js-shopping-cart
command = ["node", "index.js"]
env-vars {
DEBUG = "cloudstate-*"
}
}
},{
name = "Akka + Java"
tck {
hostname = "0.0.0.0"
Expand All @@ -43,7 +8,9 @@ cloudstate-tck.combinations = [{
hostname = "127.0.0.1"
port = 9000
directory = ${user.dir}
command = ["java","-Xmx512M", "-Xms128M", "-Dconfig.resource=in-memory.conf", "-Dcloudstate.proxy.dev-mode-enabled=true", "-jar", "proxy/core/target/scala-2.12/akka-proxy.jar"]
command = ["java","-Xmx512M", "-Xms128M",
"-Dcloudstate.proxy.dev-mode-enabled=true", "-jar", "proxy/spanner/target/scala-2.12/akka-proxy-spanner.jar"
]

env-vars {
USER_FUNCTION_PORT = "8090"
Expand All @@ -60,83 +27,4 @@ cloudstate-tck.combinations = [{
PORT = "8088"
}
}
},{
name = "Akka + Scala"
tck {
hostname = "0.0.0.0"
port = 8090
}
proxy {
hostname = "127.0.0.1"
port = 9000
directory = ${user.dir}
command = ["java","-Xmx512M", "-Xms128M", "-Dconfig.resource=in-memory.conf", "-Dcloudstate.proxy.dev-mode-enabled=true", "-jar", "proxy/core/target/scala-2.12/akka-proxy.jar"]

env-vars {
USER_FUNCTION_PORT = "8090"
}
}

frontend {
hostname = "127.0.0.1"
port = 8088
directory = ${user.dir}/samples/scala-shopping-cart
command = ["java","-Xmx512M", "-Xms128M", "-jar", "target/scala-2.12/scala-shopping-cart.jar"]
env-vars {
HOST = "127.0.0.1"
PORT = "8088"
}
}
},{
name = "Akka + Go"
tck {
hostname = "0.0.0.0"
port = 8090
}
proxy {
hostname = "127.0.0.1"
port = 9000
directory = ${user.dir}
command = ["java","-Xmx512M", "-Xms128M", "-Dconfig.resource=in-memory.conf", "-Dcloudstate.proxy.dev-mode-enabled=true", "-jar", "proxy/core/target/scala-2.12/akka-proxy.jar"]
env-vars {
USER_FUNCTION_PORT = "8090"
}
}

frontend {
hostname = "127.0.0.1"
port = 8080
directory = ${user.dir}
command = ["docker", "run", "--rm", "-p", "127.0.0.1:8080:8080", "gcr.io/mrcllnz/cloudstate-go-tck:latest"]
env-vars {
HOST = "127.0.0.1"
PORT = "8080"
}
}
},{
name = "Akka + Kotlin"
tck {
hostname = "0.0.0.0"
port = 8090
}
proxy {
hostname = "127.0.0.1"
port = 9000
directory = ${user.dir}
command = ["java","-Xmx512M", "-Xms128M", "-Dconfig.resource=in-memory.conf", "-Dcloudstate.proxy.dev-mode-enabled=true", "-jar", "proxy/core/target/scala-2.12/akka-proxy.jar"]
env-vars {
USER_FUNCTION_PORT = "8090"
}
}

frontend {
hostname = "127.0.0.1"
port = 8088
directory = ${user.dir}
command = ["docker", "run", "--rm", "-p", "127.0.0.1:8088:8080", "sleipnir/shopping-cart:latest"]
env-vars {
HOST = "127.0.0.1"
PORT = "8088"
}
}
}]