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

WIP: Remove com.sun.* dependency #40

Closed
wants to merge 1 commit into from
Closed

Conversation

gorkem
Copy link
Contributor

@gorkem gorkem commented Apr 25, 2018

Removes com.sun.* dependency. By taking vert.x as the http server. Also starts looking into the manifest.mf to infer the main class name. Manifest.mf still needs work on other repositories to be used. see #14, #12

Update: Just noticed that I broke com.example.MyMain#methodName notation for defining main method. Will update with a fix.

@gorkem gorkem changed the title Remove com.sun.* dependency WIP: Remove com.sun.* dependency Apr 25, 2018
@gorkem gorkem force-pushed the new_http branch 4 times, most recently from 468c35c to 6cd48ab Compare April 27, 2018 03:16
Removes com.sun.* dependency. Uses vert.x as
the http server. Infers main class name from
manifest.mf

Signed-off-by: Gorkem Ercan <[email protected]>
final JsonObject request = rc.getBodyAsJson();
final JsonObject value = request.getJsonObject("value");
final JsonParser parser = new JsonParser();
final com.google.gson.JsonObject req = parser.parse(value.toString()).getAsJsonObject();
Copy link

Choose a reason for hiding this comment

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

This code does:

  1. parse body to a io.vertx.core.json.JsonObject (rc.getBodyAsJson())
  2. serialize io.vertx.core.json.JsonObject to a String (value.toString())
  3. parse the serialized value to a com.google.gson.JsonObject (parser.parse())

Looks like unnecessary overhead.

router.route().failureHandler(ErrorHandler.create(true));

router.route("/init").handler(this::initHandler);
router.route("/run").handler(this::runHandler);
Copy link

Choose a reason for hiding this comment

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

Vertx handlers are supposed to execute non-blocking code using an event loop thread pool. By default, vertx even logs warnings if it detects an event loop hasn’t returned for some time. See also https://vertx.io/docs/apidocs/io/vertx/core/VertxOptions.html#DEFAULT_MAX_EVENT_LOOP_EXECUTE_TIME.

Also I'm not sure whether openwhisk runtimes can be invoked concurrently (i.e. to handle multiple events at the same time). If not we should probably tune the VertxOptions to limit the event loop and worker thread pools (e.g. event loop pool has by default 2 * number of cores on the machine).

Copy link
Member

Choose a reason for hiding this comment

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

Runtimes don’t tolerate intra container concurrency for activations but a PR is coming upstream to make this possible.

System.setSecurityManager(new WhiskSecurityManager());

try {
final com.google.gson.JsonObject out = (com.google.gson.JsonObject) this.mainMethod.invoke(null, req);

Choose a reason for hiding this comment

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

i think if you leveraged the vertx features like eventbus the function invocation would be much more reactive.
But, i think new action "kind" would be necessary as the method invocation should make the things a different way,....
what if you invoked function using event bus, e.g.:

   vertx.eventBus().<JsonObject>send("activation", <inputJsonObject>, reply - > {
       if (reply.failed()) {
          rc.response().setStatusCode(500);
       } else {
         rc.response.end(...);
      }
  }

Then the function could be just a class extending AbstractVerticle and in start() method simply consume eventBus instead of class with main method.

@mrutkows
Copy link
Contributor

@gorkem @marcinczeczko Any interest in completing this PR? I am personally interested to see both what performance #s we would get as well as trying the concurrency aspect (as this is now configurable in our NodeJS runtime and is used by some downstream providers).

@gorkem
Copy link
Contributor Author

gorkem commented Jul 29, 2019

@mrutkows Unfortunately I will not be returning to this one anytime soon.

@dgrove-oss
Copy link
Member

closing as stale

@dgrove-oss dgrove-oss closed this Jan 25, 2020
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.

6 participants