Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

Project Helidon Overview (Japanese)

67 vues

Publié le

This slides cover overview of Project Helidon (Java libraries for creating microservices), implementation tips, and running applications on custom JRE. This slides are in Japanese.

Publié dans : Logiciels
  • Soyez le premier à commenter

  • Soyez le premier à aimer ceci

Project Helidon Overview (Japanese)

  1. 1. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Project Helidon Akihiro Nishikawa Oracle Corporation Japan Java Libraries for Microservices 1
  2. 2. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 2
  3. 3. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Program Agenda What’s Helidon? Demo Diving a little bit deeply... Helidon can also run on Custom JRE! Resources 1 2 3 4 5 3
  4. 4. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. What’s Helidon? 4
  5. 5. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 5
  6. 6. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 6 • Microframework • Functional Style • Reactive • Transparent • MicroProfile • Declarative Style • CDI, JAX-RS, JSON-P • Familiar to Java EE developers
  7. 7. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 7 Java Microservice Frameworks Smaller Larger Spring Boot Microframeworks MicroProfile Based Open Liberty Full-Stack Dropwizard
  8. 8. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 8 Architecture Helidon SE Netty WebServer SecurityConfig Helidon MP CDI JAX-RS JSON-P
  9. 9. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Eclipse MicroProfile • Java EE 2016 • RedHat IBM Tomitribe Payara • • Java EE API MicroProfile API – JAX-RS, CDI, JSON-P, JSON-B – MP Config, Metrics, Health Check, Fault Tolerance, JWT Auth – Open API, OpenTracing, RestClient • 9 2.1 (2018/10/19)
  10. 10. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Reactive WebServer • Flow API • Netty • OpenTracing Metrics • JAX-RS, JSON-P support • Config • • • • • 10 Security • • • • • – OIDC – JWT – Google Login Helidon SE
  11. 11. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Helidon SE import io.helidon.webserver.Routing; import io.helidon.webserver.WebServer; public static void main(String[] args) { WebServer.create( Routing.builder() .get("/greet", (req, res) -> res.send("Hello World!")) .build()).start(); } Helidon MP import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application; public class GreetService { @GET @Path("/greet") public String getMsg() { return "Hello World!"; } } 11 SE/MP Hello World
  12. 12. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 12 CDI Extensions Preview 0.10.5 Helidon MP Helidon SE Microprofile 1.2 • WebServer, Config, Security • JSON-P • Metrics • OpenTracing • HTTP/2 (experimental) CDI Extensions MicroProfile Config CDI 2.0 CDI Extension
  13. 13. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. • MicroProfile 2.x • Reactive HTTP Client • GraalVM • Project Starter UI • Reactive storage (NoSQL, ADBA) • Open API • Eventing 13
  14. 14. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Demo 14
  15. 15. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Demo • Quickstart • Server config and startup • Basic Routing • Basic JSON handling • Docker Container Creation • Running on Kubernetes 15
  16. 16. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 16 Archetype Helidon SE mvn archetype:generate -DinteractiveMode=false ¥ -DarchetypeGroupId=io.helidon.archetypes ¥ -DarchetypeArtifactId=helidon-quickstart-se ¥ -DarchetypeVersion=0.10.5 ¥ -DgroupId=io.helidon.examples ¥ -DartifactId=quickstart-se ¥ -Dpackage=io.helidon.examples.quickstart.se Helidon MP mvn archetype:generate -DinteractiveMode=false ¥ -DarchetypeGroupId=io.helidon.archetypes ¥ -DarchetypeArtifactId=helidon-quickstart-mp ¥ -DarchetypeVersion=0.10.5 ¥ -DgroupId=io.helidon.examples ¥ -DartifactId=quickstart-mp ¥ -Dpackage=io.helidon.examples.quickstart.mp
  17. 17. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 17
  18. 18. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 18 mvn package java -jar target/quickstart-se.jar
  19. 19. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Dockerfile #FROM openjdk:8-jre-slim FROM openjdk:8-jre-alpine RUN mkdir /app COPY libs /app/libs COPY quickstart-se.jar /app CMD ["java", "-jar", "/app/quickstart-se.jar"] 19
  20. 20. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 20 Docker docker build -t quickstart-se target docker run --rm -p 8080:8080 quickstart-se
  21. 21. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. kind: Service apiVersion: v1 metadata: name: quickstart-se labels: app: quickstart-se spec: type: NodePort selector: app: quickstart-se ports: - port: 8080 targetPort: 8080 name: http --- kind: Deployment apiVersion: extensions/v1beta1 metadata: name: quickstart-se spec: replicas: 1 template: metadata: labels: app: quickstart-se version: v1 spec: containers: - name: quickstart-se image: quickstart-se:12alpine-custom imagePullPolicy: IfNotPresent ports: - containerPort: 8080 --- 21 app.yaml
  22. 22. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 22 Kubernetes kubectl create -f target/app.yaml kubectl get service
  23. 23. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Diving a little bit deeply... 23
  24. 24. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 24 Module $ jar --file=target/libs/helidon-common-0.10.5.jar --describe-module io.helidon.common jar:file:///Users/oracle/Documents/Helidon/quickstart- se8/target/libs/helidon-common-0.10.5.jar/!module-info.class exports io.helidon.common requires java.base mandated requires java.logging
  25. 25. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Server (SE) # application.yaml app: greeting: "Hello" server: sockets: - secure: port: 443 backlog: 1024 receive-buffer: 0 timeout: 60000 ssl: .... - another: port: 12041 25 ServerConfiguration serverConfig = ServerConfiguration.fromConfig(config.get("server"));
  26. 26. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. # 3 default MicroProfile Config sources: # System.getProperties() # System.getenv() # META-INF/microprofile-config.properties # default is localhost server.host=some.host # default is 7001 server.port=7011 # Helidon configuration (optional) # Length of queue for incoming connections. server.backlog: 512 # TCP receive window (Default:0) server.receive-buffer: 256 # Socket timeout (msec) defaults:0 (infinite) server.timeout: 30000 # Default is CPU_COUNT * 2 server.workers=4 # Default is not to use SSL ssl: private-key: keystore-resource-path: "certificate.p12" keystore-passphrase: "abcd" 26 Server (MP)
  27. 27. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Routing (SE) 27 MP JAX-RS 2.0 private static Routing createRouting() { return Routing.builder() .register(JsonSupport.get()) .register("/greet", new GreetService()) .build(); } public class GreetService implements Service { ... public final void update(final Routing.Rules rules) { rules .get("/", this::getDefaultMessage) .get("/{name}", this::getMessage) .put("/greeting/{greeting}", this::updateGreeting); } }
  28. 28. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. JSON 28 SE JSON-P private static Routing createRouting() { return Routing.builder() .register(JsonSupport.get()) .register("/greet", new GreetService()) .build(); } public class GreetService implements Service { ... public final void update(final Routing.Rules rules) { rules .get("/", this::getDefaultMessage) .get("/{name}", this::getMessage) .put("/greeting/{greeting}", this::updateGreeting); } }
  29. 29. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Metrics • Prometheus • maven 29 <dependencies> <dependency> <groupId>io.helidon.microprofile.metrics</groupId> <artifactId>helidon-metrics-se</artifactId> </dependency> </dependencies>
  30. 30. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 30 import io.helidon.metrics.MetricsSupport; ... final MetricsSupport metrics = MetricsSupport.create(); ... // Endpoint final MetricsSupport metrics = MetricsSupport.create(); greetService = new GreetService(); return Routing.builder() .register(JsonSupport.get()) .register(metrics) .register("/greet", greetService) .get("/alive", Main::alive) .get("/ready", Main::ready) .build(); ...
  31. 31. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 31 import io.helidon.metrics.RegistryFactory; import org.eclipse.microprofile.metrics.Counter; import org.eclipse.microprofile.metrics.MetricRegistry; ... private final MetricRegistry registry = RegistryFactory.getRegistryFactory() .get() .getRegistry(MetricRegistry.Type.APPLICATION); ... // Counter private final Counter greetCounter = registry.counter("accessctr"); ... // Counter greetCounter.inc(); ...
  32. 32. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 32 Prometheus JSON
  33. 33. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. OpenTracing • Reactive Web Server OpenTracing Zipkin • Zipkin Tracing • 33 <dependency> <groupId>io.helidon.webserver</groupId> <artifactId>helidon-webserver-zipkin</artifactId> </dependency>
  34. 34. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 34 // OpenTracing Tracer ServerConfiguration.builder() .tracer(new ZipkinTracerBuilder.forService("Tracing ") .zipkin("Zipkin URL") .build()) .build()
  35. 35. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 35 Routing Routing.builder() .register(webSecurity) .register(JsonSupport.get()) .register(MetricsSupport.create()) .get("/ready", (req, res) -> { res.status(Http.Status.OK_200); res.send("Ready!"); }) .register(StaticContentSupport.builder("/WEB", Main.class.getClassLoader()) .welcomeFileName("index.html") .build()) .register("/greet", new GreetService()) .build(); <src>/resources
  36. 36. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. • • • • Audit 36
  37. 37. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Authentication artifactId JWT Provider helidon-security-provider-jwt HTTP Basic Authorization helidon-security-provider-http-auth HTTP Digest Authorization helidon-security-provider-http-auth Header Assertion helidon-security-provider-header-atn HTTP Signatures helidon-security-provider-http-signature ABAC (Attribute based access control) Authorization helidon-security-provider-abac Google Login Authentication Provider helidon-security-provider-google-login OIDC (Open ID Connect) Authentication provider helidon-security-provider-oidc IDCS Role Mapping Provider helidon-security-provider-idcs-mapper 37
  38. 38. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 38 • • Reactive Web Server • Jersey <dependency> <groupId>io.helidon.security</groupId> <artifactId>helidon-security</artifactId> </dependency> <dependency> <groupId>io.helidon.security</groupId> <artifactId>helidon-security-integration-webserver</artifactId> </dependency> <dependency> <groupId>io.helidon.security</groupId> <artifactId>helidon-security-integration-jersey</artifactId> </dependency>
  39. 39. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. • 39 private static WebSecurity createWebSecurity(final Config config) { Security security = Security.builder() .addProvider(GoogleTokenProvider .builder() .clientId( config.get("security.properties.google-client-id") .asString())) .build(); return WebSecurity.from(security); }
  40. 40. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. (2) • Routing • 40 Routing.builder().register(webSecurity) .register(JsonSupport.get()) .register(MetricsSupport.create()) .register("/greet", new GreetService()) .build(); final Routing.Rules rules; rules.any(this::counterFilter) .get("/", this::getDefaultMessageHandler) .get("/greeting",this::getGreetingHandler) .get("/{name}", this::getMessageHandler) .put("/greeting/{greeting}", WebSecurity.authenticate(), this::updateGreetingHandler);
  41. 41. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Etcd • • 41 Etcd <dependency> <groupId>io.helidon.config</groupId> <artifactId>helidon-config-etcd</artifactId> </dependency> Config config = Config.from( EtcdConfigSourceBuilder.from(URI.create("http://my-etcd:2379"), "/config.yaml", EtcdConfigSourceBuilder.EtcdApi.v3));
  42. 42. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Helidon can also run on Custom JRE! 42
  43. 43. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 43 Java 8, 11, 12... $ docker images quickstart-se REPOSITORY TAG IMAGE ID CREATED SIZE quickstart-se 12-oracle 35675acf14d4 7 days ago 468MB quickstart-se 11-oracle c3d347de8d23 7 days ago 469MB quickstart-se 8-alpine fae858de0489 7 days ago 88.6MB quickstart-se 8-slim 3a505f8068dc 7 days ago 210MB
  44. 44. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 44 Java 8, 11, 12... $ docker images quickstart-se REPOSITORY TAG IMAGE ID CREATED SIZE quickstart-se 12-oracle 35675acf14d4 7 days ago 468MB quickstart-se 11-oracle c3d347de8d23 7 days ago 469MB quickstart-se 8-alpine fae858de0489 7 days ago 88.6MB quickstart-se 8-slim 3a505f8068dc 7 days ago 210MB
  45. 45. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. JRE • jdeps • jlink JRE 45 $ jdeps --list-deps quickstart-se.jar $ jlink --compress=2 --module-path /opt/openjdk-12/jmods ¥ --add-modules ¥ java.base,java.logging,java.sql,java.desktop ¥ --no-header-files ¥ --no-man-pages ¥ --output /linked
  46. 46. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 46 FROM openjdk:11.0.1-jdk-oraclelinux7 AS jlink-package RUN jlink --compress=2 --module-path /usr/java/openjdk-11/jmods ¥ --add-modules java.base,java.logging,java.sql,java.desktop ¥ --no-header-files ¥ --strip-debug ¥ --no-man-pages ¥ --output /linked FROM oraclelinux:7-slim COPY --from=jlink-package /linked /usr/java/openjdk-11 ENV JAVA_HOME= /usr/java/openjdk-11 ENV PATH="$PATH:$JAVA_HOME/bin" RUN mkdir /app COPY libs /app/libs COPY quickstart-se.jar /app CMD ["java", "-jar", "/app/quickstart-se.jar"]
  47. 47. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 47 1/3 $ docker images quickstart-se REPOSITORY TAG IMAGE ID CREATED SIZE quickstart-se 12-oracle-custom edafa9a43204 7 days ago 172MB quickstart-se 12-oracle 35675acf14d4 7 days ago 468MB quickstart-se 11-oracle-custom acc0127977c8 7 days ago 172MB quickstart-se 11-oracle c3d347de8d23 7 days ago 469MB quickstart-se 8-alpine fae858de0489 7 days ago 88.6MB quickstart-se 8-slim 3a505f8068dc 7 days ago 210MB
  48. 48. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 48 1/3 $ docker images quickstart-se REPOSITORY TAG IMAGE ID CREATED SIZE quickstart-se 12-oracle-custom edafa9a43204 7 days ago 172MB quickstart-se 12-oracle 35675acf14d4 7 days ago 468MB quickstart-se 11-oracle-custom acc0127977c8 7 days ago 172MB quickstart-se 11-oracle c3d347de8d23 7 days ago 469MB quickstart-se 8-alpine fae858de0489 7 days ago 88.6MB quickstart-se 8-slim 3a505f8068dc 7 days ago 210MB
  49. 49. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. • JDK Alpine Linux • Musl libc 49 Project Portola https://www.musl-libc.org/
  50. 50. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 50 Alpine Linux ... $ docker images quickstart-se REPOSITORY TAG IMAGE ID CREATED SIZE quickstart-se 12-alpine-custom d948b732d796 7 days ago 58.4MB quickstart-se 12-alpine ba31e688dcb6 7 days ago 341MB quickstart-se 12-oracle-custom edafa9a43204 7 days ago 172MB quickstart-se 12-oracle 35675acf14d4 7 days ago 468MB quickstart-se 11-oracle-custom acc0127977c8 7 days ago 172MB quickstart-se 11-oracle c3d347de8d23 7 days ago 469MB quickstart-se 8-alpine fae858de0489 7 days ago 88.6MB quickstart-se 8-slim 3a505f8068dc 7 days ago 210MB
  51. 51. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Resources 51
  52. 52. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Resources 52 https://github.com/oracle/helidon @helidon_project https://helidon.slack.com https://helidon.io
  53. 53. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Safe Harbor Statement The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 53
  54. 54. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 54

×