-
Notifications
You must be signed in to change notification settings - Fork 63
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
Support array result include sequence action #140
Support array result include sequence action #140
Conversation
Test
[root@nccddev130026 ~]# cat ~/Split.java
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
public class Split {
public static JsonArray main(JsonObject args) {
String separator = "\n";
if (args.has("separator")) {
separator = args.getAsJsonPrimitive("separator").getAsString();
}
String payLoad = "aaaa\nbbbb\ncccc";
if (args.has("payload")) {
payLoad = args.getAsJsonPrimitive("payload").getAsString();
}
JsonArray jsonArray = new JsonArray();
String[] stringArray = payLoad.split(separator);
for(String element: stringArray) {
jsonArray.add(element);
}
return jsonArray;
}
}
[root@nccddev130026 ~]# cat ~/Sort.java
import com.google.gson.JsonArray;
public class Sort {
public static JsonArray main(JsonArray args) {
JsonArray newJsonArray = new JsonArray();
for(int i=args.size()-1;i>=0;i--) {
newJsonArray.add(args.get(i).getAsString());
}
return newJsonArray;
}
}
javac -classpath "/root/gson-2.9.0.jar" Split.java
jar cvf split.jar Split.class
wsk -i action create /whisk.system/utils/split-java split.jar --main Split --kind java:8
javac -classpath "/root/gson-2.9.0.jar" Sort.java
jar cvf sort.jar Sort.class
wsk -i action create /whisk.system/utils/sort-java sort.jar --main Sort --kind java:8
wsk -i action create mySequence-java --sequence /whisk.system/utils/split-java,/whisk.system/utils/sort-java
wsk -i action invoke --result mySequence-java --param payload "aaaa\nbbbb\ncccc" -r -v |
- JsonObject is good here - JsonArray is bad here
Support json array for input param
c59c2e0
to
ea9e1bf
Compare
throw new NoSuchMethodException(mainMethodName); | ||
} | ||
mainMethod = m; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because need to support array result, cannot instantiate mainMethod in /init
step, should move this relative logic to /run
logic due to input param/out result can be JsonObject or JsonArray
case "#bogus" => | ||
s"$errPrefix java.lang.NoSuchMethodException: example.HelloWhisk.bogus(com.google.gson.JsonObject)" | ||
case _ => s"$errPrefix java.lang.NoSuchMethodException: example.HelloWhisk.main(com.google.gson.JsonObject)" | ||
case _ => s"$errPrefix java.lang.NoSuchMethodException" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to https://github.com/apache/openwhisk-runtime-java/pull/140/files#r939487201, need to change test case here for a small change as above.
core/java8actionloop/Dockerfile
Outdated
|
||
# Use AdoptOpenJDK's JDK8, OpenJ9, ubuntu | ||
FROM ibm-semeru-runtimes:open-8u332-b09-jdk-focal | ||
|
||
# select the builder to use | ||
ARG GO_PROXY_BUILD_FROM=release | ||
ARG GO_PROXY_BUILD_FROM=source |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@style95 seems change GO_PROXY_BUILD_FROM to source
is not better, but in order to support array result, must use go runtime's upstream master code.
Can we release a new version for go runtime? e.g. https://github.com/apache/openwhisk-runtime-java/blob/master/core/java8actionloop/Dockerfile#L29
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could do a wave of runtime releases, starting with the go runtime. Would be reasonable to plan to get the go runtime released this week (takes 72 hours for the vote).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dgrove-oss , due to go runtime : 1.20.0 is released, i have updated all runtime prs(support array result)'s Dockerfile to apply this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Depend on below prs:
Support array result for common action and sequence action openwhisk#5290
Support array result include sequence action openwhisk-runtime-go#170
Support array result