FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Support array result include sequence action by ningyougang · Pull Request #140 · apache/openwhisk-runtime-java · GitHub

Support array result include sequence action - #140

Merged
dgrove-oss merged 14 commits into
apache:masterfrom
ningyougang:support-array-result-include-sequence-action
Aug 15, 2022
Merged

dgrove-oss merged 14 commits into
apache:masterfrom
ningyougang:support-array-result-include-sequence-action

Conversation

ningyougang commented Jul 25, 2022 •
edited
Loading

Copy link
Copy Markdown
Contributor

Depend on below prs:

Copy link
Copy Markdown
Contributor Author

Test make java runtime to support array result for sequence action (support array as input param)'s steps as below

  • Write Split.java and Sort.java
[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;
    }
}
  • Create java sequence action & invoke it
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

ningyougang force-pushed the support-array-result-include-sequence-action branch from c59c2e0 to ea9e1bf Compare August 5, 2022 05:02
if (!existMain) {
throw new NoSuchMethodException(mainMethodName);
}
mainMethod = m;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Comment thread core/java8actionloop/Dockerfile Outdated

# select the builder to use
ARG GO_PROXY_BUILD_FROM=release
ARG GO_PROXY_BUILD_FROM=source

ningyougang Aug 6, 2022 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@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

dgrove-oss Aug 7, 2022 •
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@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.

dgrove-oss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

dgrove-oss merged commit e366197 into apache:master Aug 15, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL