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

Support array result include sequence action #140

Conversation

ningyougang
Copy link
Contributor

@ningyougang ningyougang commented Jul 25, 2022

Depend on below prs:

@ningyougang
Copy link
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 ningyougang force-pushed the support-array-result-include-sequence-action branch from c59c2e0 to ea9e1bf Compare August 5, 2022 05:02
throw new NoSuchMethodException(mainMethodName);
}
mainMethod = m;
Copy link
Contributor Author

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"
Copy link
Contributor Author

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.


# 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
Copy link
Contributor Author

@ningyougang ningyougang Aug 6, 2022

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

Copy link
Member

@dgrove-oss dgrove-oss Aug 7, 2022

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

Copy link
Contributor Author

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.

Copy link
Member

@dgrove-oss dgrove-oss left a comment

Choose a reason for hiding this comment

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

LGTM

@dgrove-oss dgrove-oss merged commit e366197 into apache:master Aug 15, 2022
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