Transcript
Page 1: Developing, managing and opening the hood of JVM REST services - L Pfannenschmidt

OSGi DevCon / QCon New York 2014

Developing,managing andopening thehood of JVMREST services

/ Lars Pfannenschmidt @leastangle

Page 2: Developing, managing and opening the hood of JVM REST services - L Pfannenschmidt

What isswookiee?

/ Lars Pfannenschmidt @leastangle

Page 3: Developing, managing and opening the hood of JVM REST services - L Pfannenschmidt

Pfannen-what?Fun-an-schmidtData Products @ Intuit Data Engineering & AnalyticsFounder of User Group

★★★ @mobilecgn★@leastangle

Page 4: Developing, managing and opening the hood of JVM REST services - L Pfannenschmidt

What is swookiee?OSGi Runtime for REST ServicesJAX-RS 2Jersey, Jetty, JacksonServices in Java, Groovy, ScalaSwagger integrationMetrics / Graphite SupportJSON Logging SupportRemote Controllable (RFC-182)EPL

★★★★★★★★★

Page 5: Developing, managing and opening the hood of JVM REST services - L Pfannenschmidt

10(-6+1) - Services

Page 6: Developing, managing and opening the hood of JVM REST services - L Pfannenschmidt

AgendaBuilding REST ServicesSwagger documentationMetricsJSON LoggingRemote Control

★★★★★

Page 7: Developing, managing and opening the hood of JVM REST services - L Pfannenschmidt

Fizz Buzzhttps://flic.kr/p/6ae8KK by Luis Linero - Some rights reserved CC BY 2.0

Page 8: Developing, managing and opening the hood of JVM REST services - L Pfannenschmidt

Any number divisible by three is replaced by the wordfizz and any divisible by five by the word buzz.

Numbers divisible by three and five become fizz buzz.

Page 9: Developing, managing and opening the hood of JVM REST services - L Pfannenschmidt

FizzBuzz v1

Page 10: Developing, managing and opening the hood of JVM REST services - L Pfannenschmidt
Page 11: Developing, managing and opening the hood of JVM REST services - L Pfannenschmidt

FizzBuzz v2

Page 12: Developing, managing and opening the hood of JVM REST services - L Pfannenschmidt

Documentationhttps://flic.kr/p/dELbZF Books HD by Abhi Sharma - Some rights reserved CC BY 2.0

Page 13: Developing, managing and opening the hood of JVM REST services - L Pfannenschmidt

FizzBuzz v3

Page 14: Developing, managing and opening the hood of JVM REST services - L Pfannenschmidt

AlternativesGood old WADL? [ ]Apiary (http://apiary.io/)RAML (http://raml.org/)...

★ here★★★

Page 15: Developing, managing and opening the hood of JVM REST services - L Pfannenschmidt

MetricsOpening the hood

https://flic.kr/p/byHbPG Broken down by orangebrompton - Some rights reserved CC BY-NC-SA 2.0

Page 16: Developing, managing and opening the hood of JVM REST services - L Pfannenschmidt

FizzBuzz v4

Page 17: Developing, managing and opening the hood of JVM REST services - L Pfannenschmidt

Logginghttps://flic.kr/p/fE5Wgb Pitt River Logs by James Wheeler - Some rights reserved CC BY-NC-SA 2.0

Page 18: Developing, managing and opening the hood of JVM REST services - L Pfannenschmidt

Enabling JSON LoggingproductionLogging = true

loggingDirectory = logs

Generated logs can be found in logs/osgi-log.json

Page 19: Developing, managing and opening the hood of JVM REST services - L Pfannenschmidt

Sample Log Entry{ "timestamp":"1402051840211", "level":"INFO", "thread":"Component Resolve Thread (Bundle 48)", "logger":"com.swookiee.runtime.metrics.MetricsToGraphiteReporter", "message":"Graphite Reporter started using configuration: GraphiteReporterConfiguration [graphiteHost=localhost, graphitePort=2003, reportingIntervalInSeconds=10, reportingEnabled=true, reportingPrefix=Demo]" "context":"default"}

Page 20: Developing, managing and opening the hood of JVM REST services - L Pfannenschmidt

Messages in JSON?Map<String, Object> map = new HashMap<>();map.put("limit", limit);map.put("result", result);logger.info("{}", map);

{ "timestamp":"1401544478570", "level":"INFO", "thread":"qtp1201555453-33", "logger":"com.swookiee.demo.logging.impl.FizzBuzzService", "message":{ "result":[ "1", "2", "Fizz", "4", "Buzz" ], "limit":5 }, "context":"default"}

Page 21: Developing, managing and opening the hood of JVM REST services - L Pfannenschmidt

Remotehttps://flic.kr/p/hm8mFS

Chernobyl NPP - Control Room No. 2 by Michael Kötter - Some rights reserved CC BY-NC-SA 2.0

Page 22: Developing, managing and opening the hood of JVM REST services - L Pfannenschmidt

Some REST calls

Page 23: Developing, managing and opening the hood of JVM REST services - L Pfannenschmidt

Deployprivate SwookieeClient getSwookieeClient() throws SwookieeClientException { SwookieClientBuilder swookieClientBuilder = SwookieClientBuilder .newTarget("localhost") .withPort(8080) .withUsernamePassword("admin", "admin123"); return swookieClientBuilder.create();}

try ( SwookieeClient swookieeClient = getSwookieeClient() ) { String installedBundle = swookieeClient.installBundle(file, true); swookieeClient.startBundle(installedBundle);} catch (SwookieeClientException ex) { logger.error("Could not install/start bundle: '{}'", ex.getMessage(), ex);}

Page 24: Developing, managing and opening the hood of JVM REST services - L Pfannenschmidt

FutureRelease versionJVM languages?OAuth2 providerIntegration testing

★★★★

Page 25: Developing, managing and opening the hood of JVM REST services - L Pfannenschmidt

Thank You!swookiee.com

/ Lars Pfannenschmidt @leastangle


Recommended