├── jdk-example ├── .java-version ├── meeting-server │ ├── .dockerignore │ ├── src │ │ └── main │ │ │ └── java │ │ │ ├── module-info.java │ │ │ └── com │ │ │ └── example │ │ │ └── jdk │ │ │ └── MeetingServer.java │ ├── Dockerfile │ └── pom.xml ├── work-server │ ├── .dockerignore │ ├── src │ │ └── main │ │ │ └── java │ │ │ ├── module-info.java │ │ │ └── com │ │ │ └── example │ │ │ └── jdk │ │ │ └── WorkServer.java │ ├── Dockerfile │ └── pom.xml ├── kubernetes-latest │ ├── work-sa.yaml │ ├── meeting-sa.yaml │ ├── work-svc.yaml │ ├── meeting-svc.yaml │ ├── meeting-deployment-latest.yaml │ └── work-deployment-latest.yaml ├── istio-auth │ ├── istio-auth-rbac.yaml │ ├── istio-rbac-work-server.yaml │ └── istio-rbac-meeting-server.yaml ├── istio-rules │ ├── meeting-dest.yaml │ ├── serviceentry.xml │ ├── gateway.yaml │ ├── work-v1v2-dest.yaml │ ├── meeting-vs-retry.yaml │ ├── work-vs.yaml │ ├── meeting-vs-503.yaml │ ├── work-vs-v1.yaml │ ├── work-vs-v2.yaml │ └── meeting-dest-cb.yaml ├── kubernetes-v1 │ ├── meeting-deployment-v1.yaml │ └── work-deployment-v1.yaml ├── kubernetes-v2 │ └── work-deployment-v2.yaml ├── README.md └── pom.xml ├── spring-boot-example ├── meeting-server │ ├── src │ │ ├── main │ │ │ ├── resources │ │ │ │ └── application.properties │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── meetingserver │ │ │ │ └── MeetingServerApplication.java │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── meetingserver │ │ │ └── MeetingServerApplicationTests.java │ ├── .mvn │ │ └── wrapper │ │ │ ├── maven-wrapper.properties │ │ │ └── maven-wrapper.jar │ ├── Dockerfile │ ├── .gitignore │ ├── pom.xml │ ├── mvnw.cmd │ └── mvnw ├── work-server │ ├── src │ │ ├── main │ │ │ ├── resources │ │ │ │ └── application.properties │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── workserver │ │ │ │ └── WorkServerApplication.java │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── workserver │ │ │ └── WorkServerApplicationTests.java │ ├── .mvn │ │ └── wrapper │ │ │ ├── maven-wrapper.properties │ │ │ └── maven-wrapper.jar │ ├── Dockerfile │ ├── .gitignore │ ├── pom.xml │ ├── mvnw.cmd │ └── mvnw ├── guestbook-ui │ ├── Dockerfile │ ├── src │ │ ├── main │ │ │ ├── resources │ │ │ │ ├── application.properties │ │ │ │ └── templates │ │ │ │ │ └── index.html │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── guestbook │ │ │ │ ├── HelloworldUiApplication.java │ │ │ │ ├── ApplicationConfig.java │ │ │ │ ├── HelloworldUiController.java │ │ │ │ ├── HelloworldService.java │ │ │ │ └── GuestbookService.java │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── guestbook │ │ │ └── HelloworldUiApplicationTests.java │ └── pom.xml ├── guestbook-service │ ├── Dockerfile │ ├── src │ │ ├── test │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── guestbook │ │ │ │ └── GuestbookServiceApplicationTests.java │ │ └── main │ │ │ ├── resources │ │ │ └── application.yaml │ │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── guestbook │ │ │ ├── MessageService.java │ │ │ ├── GuestbookServiceApplication.java │ │ │ └── Message.java │ └── pom.xml ├── helloworld-service │ ├── Dockerfile │ ├── src │ │ ├── main │ │ │ ├── resources │ │ │ │ └── application.properties │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── guestbook │ │ │ │ └── HelloworldApplication.java │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── guestbook │ │ │ └── HelloworldApplicationTests.java │ └── pom.xml ├── istio-rules │ ├── istio-auth-rbac.yaml │ ├── guestbook-ui-dest.yaml │ ├── gateway.yaml │ ├── guestbook-ui-vs.yaml │ ├── guestbook-service-retry.yaml │ ├── guestbook-service-503.yaml │ ├── guestbook-ui-vs-v1.yaml │ ├── guestbook-ui-vs-delay.yaml │ ├── guestbook-ui-vs-20p-v2.yaml │ ├── guestbook-service-dest.yaml │ ├── istio-role-webuser.yaml │ ├── guestbook-ui-vs-chrome.yaml │ ├── istio-role-guestbook-service-rw.yaml │ ├── istio-role-viewer.yaml │ └── guestbook-service-deny.yaml ├── kubernetes-mtls │ ├── service-accounts.yaml │ ├── redis-service.yaml │ ├── mysql-pvc.yaml │ ├── ui-service.yaml │ ├── guestbook-service.yaml │ ├── helloworld-service.yaml │ ├── mysql-service.yaml │ ├── redis-deployment.yaml │ ├── guestbook-deployment-v1.yaml │ ├── mysql-deployment.yaml │ ├── helloworld-deployment-v1.yaml │ ├── ui-deployment-v1.yaml │ └── ui-deployment-v2.yaml ├── kubernetes │ ├── mysql-pvc.yaml │ ├── redis-service.yaml │ ├── ui-service.yaml │ ├── guestbook-service.yaml │ ├── helloworld-service.yaml │ ├── mysql-service.yaml │ ├── redis-deployment.yaml │ ├── guestbook-deployment-v1.yaml │ ├── helloworld-deployment-v1.yaml │ ├── mysql-deployment.yaml │ └── ui-deployment-v1.yaml ├── README.md ├── kubernetes-v2 │ ├── ui-deployment-v2.yaml │ └── helloworld-deployment-v2.yaml └── pom.xml ├── README.md ├── .gitignore ├── pom.xml ├── CONTRIBUTING.md ├── visualizer ├── style.css ├── index.html ├── script.js └── LICENSE └── LICENSE /jdk-example/.java-version: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /jdk-example/meeting-server/.dockerignore: -------------------------------------------------------------------------------- 1 | **/* 2 | !target/*.jar 3 | -------------------------------------------------------------------------------- /jdk-example/work-server/.dockerignore: -------------------------------------------------------------------------------- 1 | **/* 2 | !target/*.jar 3 | -------------------------------------------------------------------------------- /spring-boot-example/meeting-server/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8081 2 | -------------------------------------------------------------------------------- /jdk-example/meeting-server/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module com.example.jdk { 2 | requires jdk.httpserver; 3 | } 4 | -------------------------------------------------------------------------------- /jdk-example/kubernetes-latest/work-sa.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: work-server 5 | -------------------------------------------------------------------------------- /jdk-example/kubernetes-latest/meeting-sa.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: meeting-server 5 | -------------------------------------------------------------------------------- /spring-boot-example/work-server/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.sleuth.propagation-keys=x-request-id,x-ot-span-context -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is the source code material for the Istio Codelab. 2 | 3 | See [Istio Code Lab](http://bit.ly/istio-lab) for setup instructions. 4 | -------------------------------------------------------------------------------- /jdk-example/work-server/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module com.example.jdk { 2 | requires jdk.httpserver; 3 | requires jdk.incubator.httpclient; 4 | } 5 | -------------------------------------------------------------------------------- /jdk-example/meeting-server/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:9-jre-slim 2 | COPY target/meeting-server-1.0-SNAPSHOT.jar /app.jar 3 | 4 | ENTRYPOINT ["java", "-jar", "/app.jar"] 5 | -------------------------------------------------------------------------------- /spring-boot-example/work-server/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.3/apache-maven-3.5.3-bin.zip 2 | -------------------------------------------------------------------------------- /spring-boot-example/meeting-server/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.3/apache-maven-3.5.3-bin.zip 2 | -------------------------------------------------------------------------------- /spring-boot-example/work-server/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saturnism/istio-by-example-java/HEAD/spring-boot-example/work-server/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-boot-example/meeting-server/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saturnism/istio-by-example-java/HEAD/spring-boot-example/meeting-server/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-boot-example/work-server/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8u131-jre-alpine 2 | 3 | COPY target/work-server-0.0.1-SNAPSHOT.jar /app/app.jar 4 | 5 | ENTRYPOINT ["java", "-jar", "/app/app.jar"] 6 | -------------------------------------------------------------------------------- /spring-boot-example/meeting-server/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8u131-jre-alpine 2 | 3 | COPY target/meeting-server-0.0.1-SNAPSHOT.jar /app/app.jar 4 | 5 | ENTRYPOINT ["java", "-jar", "/app/app.jar"] 6 | -------------------------------------------------------------------------------- /jdk-example/work-server/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:9-jre-slim 2 | COPY target/work-server-1.0-SNAPSHOT.jar /app.jar 3 | 4 | ENTRYPOINT ["java", "--add-modules", "jdk.incubator.httpclient", "-jar", "/app.jar"] 5 | -------------------------------------------------------------------------------- /spring-boot-example/guestbook-ui/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8u131-jre-alpine 2 | 3 | COPY target/lib/* /app/lib/ 4 | COPY target/guestbook-ui-0.0.1-SNAPSHOT.jar /app/app.jar 5 | 6 | ENTRYPOINT ["java", "-jar", "/app/app.jar"] 7 | -------------------------------------------------------------------------------- /jdk-example/istio-auth/istio-auth-rbac.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: "rbac.istio.io/v1alpha1" 2 | kind: RbacConfig 3 | metadata: 4 | name: default 5 | spec: 6 | mode: 'ON_WITH_INCLUSION' 7 | inclusion: 8 | namespaces: ["default"] 9 | -------------------------------------------------------------------------------- /spring-boot-example/guestbook-service/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8u131-jre-alpine 2 | 3 | COPY target/lib/* /app/lib/ 4 | COPY target/guestbook-service-0.0.1-SNAPSHOT.jar /app/app.jar 5 | 6 | ENTRYPOINT ["java", "-jar", "/app/app.jar"] 7 | -------------------------------------------------------------------------------- /spring-boot-example/helloworld-service/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8u131-jre-alpine 2 | 3 | COPY target/lib/* /app/lib/ 4 | COPY target/helloworld-service-0.0.1-SNAPSHOT.jar /app/app.jar 5 | 6 | ENTRYPOINT ["java", "-jar", "/app/app.jar"] 7 | -------------------------------------------------------------------------------- /spring-boot-example/istio-rules/istio-auth-rbac.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: "rbac.istio.io/v1alpha1" 2 | kind: RbacConfig 3 | metadata: 4 | name: default 5 | spec: 6 | mode: 'ON_WITH_INCLUSION' 7 | inclusion: 8 | namespaces: ["default"] 9 | -------------------------------------------------------------------------------- /spring-boot-example/helloworld-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | version=1.0 2 | greeting=Hello $name from $hostname with $version 3 | spring.application.name=helloworld-service 4 | spring.sleuth.propagation-keys=x-request-id,x-ot-span-context 5 | -------------------------------------------------------------------------------- /jdk-example/istio-rules/meeting-dest.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.istio.io/v1alpha3 2 | kind: DestinationRule 3 | metadata: 4 | name: meeting-server 5 | spec: 6 | host: meeting-server 7 | trafficPolicy: 8 | loadBalancer: 9 | simple: ROUND_ROBIN 10 | -------------------------------------------------------------------------------- /jdk-example/istio-rules/serviceentry.xml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.istio.io/v1alpha3 2 | kind: ServiceEntry 3 | metadata: 4 | name: debian 5 | spec: 6 | hosts: 7 | - "*.debian.org" 8 | location: MESH_EXTERNAL 9 | ports: 10 | - number: 80 11 | name: http 12 | protocol: HTTP 13 | -------------------------------------------------------------------------------- /jdk-example/istio-rules/gateway.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.istio.io/v1alpha3 2 | kind: Gateway 3 | metadata: 4 | name: work-gateway 5 | spec: 6 | selector: 7 | istio: ingressgateway 8 | servers: 9 | - hosts: 10 | - "*" 11 | port: 12 | number: 80 13 | name: http 14 | protocol: HTTP 15 | -------------------------------------------------------------------------------- /jdk-example/istio-rules/work-v1v2-dest.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.istio.io/v1alpha3 2 | kind: DestinationRule 3 | metadata: 4 | name: work-server 5 | spec: 6 | host: work-server 7 | subsets: 8 | - name: v1 9 | labels: 10 | version: "latest" 11 | - name: v2 12 | labels: 13 | version: "2.0" 14 | -------------------------------------------------------------------------------- /spring-boot-example/istio-rules/guestbook-ui-dest.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.istio.io/v1alpha3 2 | kind: DestinationRule 3 | metadata: 4 | name: guestbook-ui 5 | spec: 6 | host: guestbook-ui 7 | subsets: 8 | - name: v1 9 | labels: 10 | version: "1.0" 11 | - name: v2 12 | labels: 13 | version: "2.0" 14 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes-mtls/service-accounts.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: guestbook-ui 5 | --- 6 | apiVersion: v1 7 | kind: ServiceAccount 8 | metadata: 9 | name: guestbook-service 10 | --- 11 | apiVersion: v1 12 | kind: ServiceAccount 13 | metadata: 14 | name: helloworld-service 15 | -------------------------------------------------------------------------------- /spring-boot-example/istio-rules/gateway.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.istio.io/v1alpha3 2 | kind: Gateway 3 | metadata: 4 | name: guestbook-gateway 5 | spec: 6 | selector: 7 | istio: ingressgateway 8 | servers: 9 | - hosts: 10 | - "*" 11 | port: 12 | number: 80 13 | name: http 14 | protocol: HTTP 15 | 16 | -------------------------------------------------------------------------------- /jdk-example/istio-rules/meeting-vs-retry.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.istio.io/v1alpha3 2 | kind: VirtualService 3 | metadata: 4 | name: meeting-server 5 | spec: 6 | hosts: 7 | - meeting-server 8 | http: 9 | - route: 10 | - destination: 11 | host: meeting-server 12 | retries: 13 | attempts: 3 14 | perTryTimeout: 2s 15 | -------------------------------------------------------------------------------- /jdk-example/istio-rules/work-vs.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.istio.io/v1alpha3 2 | kind: VirtualService 3 | metadata: 4 | name: work-server 5 | spec: 6 | hosts: 7 | - "*" 8 | gateways: 9 | - work-gateway 10 | http: 11 | - match: 12 | - uri: 13 | prefix: /work 14 | route: 15 | - destination: 16 | host: work-server 17 | -------------------------------------------------------------------------------- /spring-boot-example/istio-rules/guestbook-ui-vs.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.istio.io/v1alpha3 2 | kind: VirtualService 3 | metadata: 4 | name: guestbook-ui 5 | spec: 6 | hosts: 7 | - "*" 8 | gateways: 9 | - guestbook-gateway 10 | http: 11 | - match: 12 | - uri: 13 | prefix: / 14 | route: 15 | - destination: 16 | host: guestbook-ui 17 | -------------------------------------------------------------------------------- /jdk-example/istio-rules/meeting-vs-503.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.istio.io/v1alpha3 2 | kind: VirtualService 3 | metadata: 4 | name: meeting-server 5 | spec: 6 | hosts: 7 | - meeting-server 8 | http: 9 | - route: 10 | - destination: 11 | host: meeting-server 12 | fault: 13 | abort: 14 | percent: 100 15 | httpStatus: 503 16 | 17 | -------------------------------------------------------------------------------- /spring-boot-example/istio-rules/guestbook-service-retry.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.istio.io/v1alpha3 2 | kind: VirtualService 3 | metadata: 4 | name: guestbook-service 5 | spec: 6 | hosts: 7 | - guestbook-service 8 | http: 9 | - route: 10 | - destination: 11 | host: guestbook-service 12 | retries: 13 | attempts: 3 14 | perTryTimeout: 2s 15 | -------------------------------------------------------------------------------- /spring-boot-example/guestbook-ui/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=ui 2 | backend.guestbook-service.url=http://guestbook-service:8080/messages 3 | backend.helloworld-service.url=http://helloworld-service:8080/hello 4 | spring.redis.host=redis 5 | spring.redis.port=6379 6 | spring.session.store-type=redis 7 | spring.sleuth.propagation-keys=x-request-id,x-ot-span-context 8 | -------------------------------------------------------------------------------- /spring-boot-example/istio-rules/guestbook-service-503.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.istio.io/v1alpha3 2 | kind: VirtualService 3 | metadata: 4 | name: guestbook-service 5 | spec: 6 | hosts: 7 | - guestbook-service 8 | http: 9 | - route: 10 | - destination: 11 | host: guestbook-service 12 | fault: 13 | abort: 14 | percent: 100 15 | httpStatus: 503 16 | 17 | -------------------------------------------------------------------------------- /spring-boot-example/istio-rules/guestbook-ui-vs-v1.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.istio.io/v1alpha3 2 | kind: VirtualService 3 | metadata: 4 | name: guestbook-ui 5 | spec: 6 | hosts: 7 | - "*" 8 | gateways: 9 | - guestbook-gateway 10 | http: 11 | - match: 12 | - uri: 13 | prefix: / 14 | route: 15 | - destination: 16 | host: guestbook-ui 17 | subset: v1 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ 25 | 26 | ### Mac OSX ### 27 | .DS_Store 28 | -------------------------------------------------------------------------------- /spring-boot-example/work-server/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /spring-boot-example/meeting-server/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /spring-boot-example/istio-rules/guestbook-ui-vs-delay.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.istio.io/v1alpha3 2 | kind: VirtualService 3 | metadata: 4 | name: guestbook-ui 5 | spec: 6 | hosts: 7 | - "*" 8 | gateways: 9 | - guestbook-gateway 10 | http: 11 | - match: 12 | - uri: 13 | prefix: / 14 | route: 15 | - destination: 16 | host: guestbook-ui 17 | subset: v1 18 | fault: 19 | delay: 20 | percent: 100 21 | fixedDelay: 5s 22 | -------------------------------------------------------------------------------- /jdk-example/istio-rules/work-vs-v1.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.istio.io/v1alpha3 2 | kind: VirtualService 3 | metadata: 4 | name: work-server 5 | spec: 6 | hosts: 7 | - "*" 8 | gateways: 9 | - work-gateway 10 | http: 11 | - match: 12 | - uri: 13 | prefix: /work 14 | route: 15 | - destination: 16 | host: work-server 17 | subset: v1 18 | weight: 100 19 | - destination: 20 | host: work-server 21 | subset: v2 22 | weight: 0 23 | -------------------------------------------------------------------------------- /jdk-example/istio-rules/work-vs-v2.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.istio.io/v1alpha3 2 | kind: VirtualService 3 | metadata: 4 | name: work-server 5 | spec: 6 | hosts: 7 | - "*" 8 | gateways: 9 | - work-gateway 10 | http: 11 | - match: 12 | - uri: 13 | prefix: /work 14 | route: 15 | - destination: 16 | host: work-server 17 | subset: v1 18 | weight: 0 19 | - destination: 20 | host: work-server 21 | subset: v2 22 | weight: 100 23 | -------------------------------------------------------------------------------- /spring-boot-example/work-server/src/test/java/com/example/workserver/WorkServerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.workserver; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class WorkServerApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-example/istio-rules/guestbook-ui-vs-20p-v2.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.istio.io/v1alpha3 2 | kind: VirtualService 3 | metadata: 4 | name: guestbook-ui 5 | spec: 6 | hosts: 7 | - "*" 8 | gateways: 9 | - guestbook-gateway 10 | http: 11 | - match: 12 | - uri: 13 | prefix: / 14 | route: 15 | - destination: 16 | host: guestbook-ui 17 | subset: v1 18 | weight: 80 19 | - destination: 20 | host: guestbook-ui 21 | subset: v2 22 | weight: 20 23 | -------------------------------------------------------------------------------- /spring-boot-example/meeting-server/src/test/java/com/example/meetingserver/MeetingServerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.meetingserver; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class MeetingServerApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-example/istio-rules/guestbook-service-dest.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.istio.io/v1alpha3 2 | kind: DestinationRule 3 | metadata: 4 | name: guestbook-service 5 | spec: 6 | host: guestbook-service 7 | trafficPolicy: 8 | connectionPool: 9 | tcp: 10 | maxConnections: 100 11 | http: 12 | maxRequestsPerConnection: 10 13 | http1MaxPendingRequests: 1024 14 | outlierDetection: 15 | http: 16 | consecutiveErrors: 7 17 | interval: 5m 18 | baseEjectionTime: 15m 19 | -------------------------------------------------------------------------------- /jdk-example/istio-rules/meeting-dest-cb.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.istio.io/v1alpha3 2 | kind: DestinationRule 3 | metadata: 4 | name: meeting-server 5 | spec: 6 | host: meeting-server 7 | trafficPolicy: 8 | loadBalancer: 9 | simple: ROUND_ROBIN 10 | connectionPool: 11 | tcp: 12 | maxConnections: 100 13 | http: 14 | maxRequestsPerConnection: 10 15 | http1MaxPendingRequests: 1024 16 | outlierDetection: 17 | http: 18 | consecutiveErrors: 7 19 | interval: 5m 20 | baseEjectionTime: 15m 21 | -------------------------------------------------------------------------------- /spring-boot-example/istio-rules/istio-role-webuser.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: "rbac.istio.io/v1alpha1" 2 | kind: ServiceRole 3 | metadata: 4 | name: webuser 5 | namespace: default 6 | spec: 7 | rules: 8 | - services: ["guestbook-ui.default.svc.cluster.local"] 9 | methods: ["*"] 10 | --- 11 | apiVersion: rbac.istio.io/v1alpha1 12 | kind: ServiceRoleBinding 13 | metadata: 14 | name: bind-webuser 15 | namespace: default 16 | spec: 17 | subjects: 18 | - properties: 19 | source.namespace: istio-system 20 | roleRef: 21 | kind: ServiceRole 22 | name: webuser 23 | -------------------------------------------------------------------------------- /jdk-example/istio-auth/istio-rbac-work-server.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: "rbac.istio.io/v1alpha1" 2 | kind: ServiceRole 3 | metadata: 4 | name: work-server-webuser 5 | namespace: default 6 | spec: 7 | rules: 8 | - services: ["work-server.default.svc.cluster.local"] 9 | methods: ["*"] 10 | --- 11 | apiVersion: rbac.istio.io/v1alpha1 12 | kind: ServiceRoleBinding 13 | metadata: 14 | name: bind-work-server-webuser 15 | namespace: default 16 | spec: 17 | subjects: 18 | - properties: 19 | source.namespace: istio-system 20 | roleRef: 21 | kind: ServiceRole 22 | name: work-server-webuser 23 | -------------------------------------------------------------------------------- /jdk-example/istio-auth/istio-rbac-meeting-server.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: "rbac.istio.io/v1alpha1" 2 | kind: ServiceRole 3 | metadata: 4 | name: meeting-server-viewer 5 | namespace: default 6 | spec: 7 | rules: 8 | - services: ["meeting-server.default.svc.cluster.local"] 9 | methods: ["GET"] 10 | --- 11 | apiVersion: "rbac.istio.io/v1alpha1" 12 | kind: ServiceRoleBinding 13 | metadata: 14 | name: meeting-server-viewer-binding 15 | namespace: default 16 | spec: 17 | subjects: 18 | - user: "cluster.local/ns/default/sa/work-server" 19 | roleRef: 20 | kind: ServiceRole 21 | name: meeting-server-viewer 22 | -------------------------------------------------------------------------------- /spring-boot-example/istio-rules/guestbook-ui-vs-chrome.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.istio.io/v1alpha3 2 | kind: VirtualService 3 | metadata: 4 | name: guestbook-ui 5 | spec: 6 | hosts: 7 | - "*" 8 | gateways: 9 | - guestbook-gateway 10 | http: 11 | - match: 12 | - uri: 13 | prefix: / 14 | headers: 15 | user-agent: 16 | regex: ".*Chrome.*" 17 | route: 18 | - destination: 19 | host: guestbook-ui 20 | subset: v2 21 | - match: 22 | - uri: 23 | prefix: / 24 | route: 25 | - destination: 26 | host: guestbook-ui 27 | subset: v1 28 | 29 | -------------------------------------------------------------------------------- /spring-boot-example/istio-rules/istio-role-guestbook-service-rw.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: "rbac.istio.io/v1alpha1" 2 | kind: ServiceRole 3 | metadata: 4 | name: guestbook-service-rw 5 | namespace: default 6 | spec: 7 | rules: 8 | - services: ["guestbook-service.default.svc.cluster.local"] 9 | methods: ["*"] 10 | --- 11 | apiVersion: rbac.istio.io/v1alpha1 12 | kind: ServiceRoleBinding 13 | metadata: 14 | name: bind-guestbook-service-rw 15 | namespace: default 16 | spec: 17 | subjects: 18 | - properties: 19 | source.principal: cluster.local/ns/default/sa/guestbook-ui 20 | roleRef: 21 | kind: ServiceRole 22 | name: guestbook-service-rw 23 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.example.istio 8 | istio-by-example 9 | pom 10 | 1.0-SNAPSHOT 11 | Examples of how to use Istio in Java 12 | 13 | spring-boot-example 14 | jdk-example 15 | 16 | 17 | -------------------------------------------------------------------------------- /spring-boot-example/istio-rules/istio-role-viewer.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: "rbac.istio.io/v1alpha1" 2 | kind: ServiceRole 3 | metadata: 4 | name: viewer 5 | namespace: default 6 | spec: 7 | rules: 8 | - services: ["guestbook-service.default.svc.cluster.local", "helloworld-service.default.svc.cluster.local", "guestbook-ui.default.svc.cluster.local"] 9 | methods: ["GET", "HEAD"] 10 | --- 11 | apiVersion: rbac.istio.io/v1alpha1 12 | kind: ServiceRoleBinding 13 | metadata: 14 | name: bind-viewer 15 | namespace: default 16 | spec: 17 | subjects: 18 | - properties: 19 | source.namespace: istio-system 20 | - properties: 21 | source.namespace: default 22 | roleRef: 23 | kind: ServiceRole 24 | name: viewer 25 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes/mysql-pvc.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | kind: PersistentVolumeClaim 16 | apiVersion: v1 17 | metadata: 18 | name: mysql-pvc 19 | spec: 20 | accessModes: 21 | - ReadWriteOnce 22 | resources: 23 | requests: 24 | storage: 5Gi 25 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes/redis-service.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | kind: Service 16 | apiVersion: v1 17 | metadata: 18 | name: redis 19 | labels: 20 | app: redis 21 | visualize: "true" 22 | spec: 23 | ports: 24 | - port: 6379 25 | targetPort: 6379 26 | name: redis 27 | selector: 28 | app: redis 29 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes-mtls/redis-service.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | kind: Service 16 | apiVersion: v1 17 | metadata: 18 | name: redis 19 | labels: 20 | app: redis 21 | visualize: "true" 22 | spec: 23 | ports: 24 | - port: 6379 25 | targetPort: 6379 26 | name: redis 27 | selector: 28 | app: redis 29 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes-mtls/mysql-pvc.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | kind: PersistentVolumeClaim 16 | apiVersion: v1 17 | metadata: 18 | name: mysql-pvc 19 | annotations: 20 | volume.beta.kubernetes.io/storage-class: standard 21 | spec: 22 | accessModes: 23 | - ReadWriteOnce 24 | resources: 25 | requests: 26 | storage: 5Gi 27 | -------------------------------------------------------------------------------- /spring-boot-example/istio-rules/guestbook-service-deny.yaml: -------------------------------------------------------------------------------- 1 | # Create a denier that returns a google.rpc.Code 7 (PERMISSION_DENIED) 2 | apiVersion: config.istio.io/v1alpha2 3 | kind: denier 4 | metadata: 5 | name: denyall 6 | namespace: istio-system 7 | spec: 8 | status: 9 | code: 7 10 | message: Not allowed 11 | --- 12 | # The (empty) data handed to denyall at run time 13 | apiVersion: config.istio.io/v1alpha2 14 | kind: checknothing 15 | metadata: 16 | name: denyrequest 17 | namespace: istio-system 18 | spec: 19 | --- 20 | # The rule that uses denier to deny requests with source.labels["app"] == "helloworld-service" 21 | apiVersion: config.istio.io/v1alpha2 22 | kind: rule 23 | metadata: 24 | name: deny-guestbook-service 25 | namespace: istio-system 26 | spec: 27 | match: destination.service=="guestbook-service.default.svc.cluster.local" 28 | actions: 29 | - handler: denyall.denier 30 | instances: 31 | - denyrequest.checknothing 32 | -------------------------------------------------------------------------------- /jdk-example/kubernetes-latest/work-svc.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | kind: Service 16 | apiVersion: v1 17 | metadata: 18 | name: work-server 19 | labels: 20 | app: work-server 21 | visualize: "true" 22 | spec: 23 | ports: 24 | - port: 8080 25 | targetPort: 8080 26 | name: http 27 | selector: 28 | app: work-server 29 | serving: "true" 30 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes/ui-service.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | kind: Service 16 | apiVersion: v1 17 | metadata: 18 | name: guestbook-ui 19 | labels: 20 | app: guestbook-ui 21 | visualize: "true" 22 | spec: 23 | ports: 24 | - port: 8080 25 | targetPort: 8080 26 | name: http 27 | selector: 28 | app: guestbook-ui 29 | serving: "true" 30 | -------------------------------------------------------------------------------- /jdk-example/kubernetes-latest/meeting-svc.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | kind: Service 16 | apiVersion: v1 17 | metadata: 18 | name: meeting-server 19 | labels: 20 | app: meeting-server 21 | visualize: "true" 22 | spec: 23 | ports: 24 | - port: 8081 25 | targetPort: 8081 26 | name: http 27 | selector: 28 | app: meeting-server 29 | serving: "true" 30 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes-mtls/ui-service.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | kind: Service 16 | apiVersion: v1 17 | metadata: 18 | name: guestbook-ui 19 | labels: 20 | app: guestbook-ui 21 | visualize: "true" 22 | spec: 23 | ports: 24 | - port: 8080 25 | targetPort: 8080 26 | name: http 27 | selector: 28 | app: guestbook-ui 29 | serving: "true" 30 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes/guestbook-service.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | kind: Service 16 | apiVersion: v1 17 | metadata: 18 | name: guestbook-service 19 | labels: 20 | app: guestbook-service 21 | visualize: "true" 22 | spec: 23 | ports: 24 | - port: 80 25 | targetPort: 8080 26 | name: http 27 | selector: 28 | app: guestbook-service 29 | serving: "true" 30 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes-mtls/guestbook-service.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | kind: Service 16 | apiVersion: v1 17 | metadata: 18 | name: guestbook-service 19 | labels: 20 | app: guestbook-service 21 | visualize: "true" 22 | spec: 23 | ports: 24 | - port: 80 25 | targetPort: 8080 26 | name: http 27 | selector: 28 | app: guestbook-service 29 | serving: "true" 30 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes/helloworld-service.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | kind: Service 16 | apiVersion: v1 17 | metadata: 18 | name: helloworld-service 19 | labels: 20 | app: helloworld-service 21 | visualize: "true" 22 | spec: 23 | ports: 24 | - port: 8080 25 | targetPort: 8080 26 | name: http 27 | selector: 28 | app: helloworld-service 29 | serving: "true" 30 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes-mtls/helloworld-service.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | kind: Service 16 | apiVersion: v1 17 | metadata: 18 | name: helloworld-service 19 | labels: 20 | app: helloworld-service 21 | visualize: "true" 22 | spec: 23 | ports: 24 | - port: 8080 25 | targetPort: 8080 26 | name: http 27 | selector: 28 | app: helloworld-service 29 | serving: "true" 30 | -------------------------------------------------------------------------------- /spring-boot-example/meeting-server/src/main/java/com/example/meetingserver/MeetingServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.meetingserver; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | @SpringBootApplication 11 | @RestController 12 | public class MeetingServerApplication { 13 | private static Logger logger = LoggerFactory.getLogger(MeetingServerApplication.class); 14 | 15 | @GetMapping("/meet") 16 | public void meeting() { 17 | logger.info("Meeting for work!"); 18 | try { 19 | Thread.sleep(250L); 20 | } 21 | catch (InterruptedException e) { 22 | // do nothing 23 | } 24 | } 25 | 26 | public static void main(String[] args) { 27 | SpringApplication.run(MeetingServerApplication.class, args); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes/mysql-service.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: v1 16 | kind: Service 17 | metadata: 18 | name: mysql 19 | labels: 20 | app: mysql 21 | visualize: "true" 22 | spec: 23 | ports: 24 | # the port that this service should serve on 25 | - port: 3306 26 | name: mysql 27 | # label keys and values that must match in order to receive traffic for this service 28 | selector: 29 | app: mysql 30 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes-mtls/mysql-service.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: v1 16 | kind: Service 17 | metadata: 18 | name: mysql 19 | labels: 20 | app: mysql 21 | visualize: "true" 22 | spec: 23 | ports: 24 | # the port that this service should serve on 25 | - port: 3306 26 | name: mysql 27 | # label keys and values that must match in order to receive traffic for this service 28 | selector: 29 | app: mysql 30 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to Contribute 2 | 3 | We'd love to accept your patches and contributions to this project. There are 4 | just a few small guidelines you need to follow. 5 | 6 | ## Contributor License Agreement 7 | 8 | Contributions to this project must be accompanied by a Contributor License 9 | Agreement. You (or your employer) retain the copyright to your contribution, 10 | this simply gives us permission to use and redistribute your contributions as 11 | part of the project. Head over to to see 12 | your current agreements on file or to sign a new one. 13 | 14 | You generally only need to submit a CLA once, so if you've already submitted one 15 | (even if it was for a different project), you probably don't need to do it 16 | again. 17 | 18 | ## Code reviews 19 | 20 | All submissions, including submissions by project members, require review. We 21 | use GitHub pull requests for this purpose. Consult 22 | [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more 23 | information on using pull requests. 24 | -------------------------------------------------------------------------------- /visualizer/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: helvetica; 3 | } 4 | 5 | .logo { 6 | background: url('titlelogo.svg'); 7 | background-repeat: no-repeat; 8 | height: 150px; 9 | width: 600px; 10 | } 11 | 12 | .navbar-logo { 13 | margin-left: 0px; 14 | margin-top: 0px; 15 | } 16 | 17 | #nav-logo-img { 18 | height: 42px; 19 | } 20 | 21 | .navbar { 22 | position: absolute; 23 | padding: 5px; 24 | left: 0; 25 | top: 0; 26 | right: 0; 27 | background-color: #447AE8; 28 | border: 0px; 29 | border-radius: 0; 30 | } 31 | 32 | .demo { 33 | position: absolute; 34 | padding: 5%; 35 | left: 0; 36 | right: 0; 37 | top: 50px; 38 | height: 100%; 39 | } 40 | 41 | span { 42 | display: block; 43 | font-size: 1.2em; 44 | clear: left; 45 | padding: 0.5em; 46 | } 47 | 48 | .pod { 49 | border-radius: 4px; 50 | width: 40px; 51 | height: 40px; 52 | margin: 2px; 53 | float: left; 54 | } 55 | 56 | .running { 57 | background-color: #297b48; 58 | } 59 | 60 | .pending { 61 | /* background-color: #7bb992; */ 62 | background-color: #297b48; 63 | } 64 | 65 | .terminating { 66 | background-color: #d47d6a; 67 | } 68 | -------------------------------------------------------------------------------- /spring-boot-example/guestbook-ui/src/test/java/com/example/guestbook/HelloworldUiApplicationTests.java: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // TODO: High-level file comment. 16 | 17 | package com.example.guestbook; 18 | 19 | import org.junit.Test; 20 | import org.junit.runner.RunWith; 21 | import org.springframework.boot.test.context.SpringBootTest; 22 | import org.springframework.test.context.junit4.SpringRunner; 23 | 24 | @RunWith(SpringRunner.class) 25 | @SpringBootTest 26 | public class HelloworldUiApplicationTests { 27 | 28 | @Test 29 | public void contextLoads() { 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /spring-boot-example/helloworld-service/src/test/java/com/example/guestbook/HelloworldApplicationTests.java: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // TODO: High-level file comment. 16 | 17 | package com.example.guestbook; 18 | 19 | import org.junit.Test; 20 | import org.junit.runner.RunWith; 21 | import org.springframework.boot.test.context.SpringBootTest; 22 | import org.springframework.test.context.junit4.SpringRunner; 23 | 24 | @RunWith(SpringRunner.class) 25 | @SpringBootTest 26 | public class HelloworldApplicationTests { 27 | 28 | @Test 29 | public void contextLoads() { 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /spring-boot-example/guestbook-service/src/test/java/com/example/guestbook/GuestbookServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // TODO: High-level file comment. 16 | 17 | package com.example.guestbook; 18 | 19 | import org.junit.Test; 20 | import org.junit.runner.RunWith; 21 | import org.springframework.boot.test.context.SpringBootTest; 22 | import org.springframework.test.context.junit4.SpringRunner; 23 | 24 | @RunWith(SpringRunner.class) 25 | @SpringBootTest 26 | public class GuestbookServiceApplicationTests { 27 | 28 | @Test 29 | public void contextLoads() { 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /jdk-example/kubernetes-v1/meeting-deployment-v1.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: extensions/v1beta1 16 | kind: Deployment 17 | metadata: 18 | name: meeting-server-v1 19 | labels: 20 | app: meeting-server 21 | version: "1.0" 22 | visualize: "true" 23 | spec: 24 | replicas: 2 25 | template: 26 | metadata: 27 | labels: 28 | app: meeting-server 29 | serving: "true" 30 | version: "1.0" 31 | visualize: "true" 32 | spec: 33 | containers: 34 | - name: meeting-server 35 | image: saturnism/meeting-server-istio:v1 36 | ports: 37 | - containerPort: 8081 38 | name: http 39 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes/redis-deployment.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: apps/v1 16 | kind: Deployment 17 | metadata: 18 | name: redis 19 | labels: 20 | app: redis 21 | visualize: "true" 22 | spec: 23 | replicas: 1 24 | selector: 25 | matchLabels: 26 | app: redis 27 | version: "4.0.2" 28 | template: 29 | metadata: 30 | labels: 31 | app: redis 32 | version: "4.0.2" 33 | visualize: "true" 34 | spec: 35 | containers: 36 | - name: redis 37 | image: redis:4.0.2 38 | livenessProbe: 39 | tcpSocket: 40 | port: 6379 41 | ports: 42 | - name: redis-server 43 | containerPort: 6379 44 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes-mtls/redis-deployment.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: apps/v1 16 | kind: Deployment 17 | metadata: 18 | name: redis 19 | labels: 20 | app: redis 21 | visualize: "true" 22 | spec: 23 | replicas: 1 24 | selector: 25 | matchLabels: 26 | app: redis 27 | version: "4.0.2" 28 | template: 29 | metadata: 30 | labels: 31 | app: redis 32 | version: "4.0.2" 33 | visualize: "true" 34 | spec: 35 | containers: 36 | - name: redis 37 | image: redis:4.0.2 38 | livenessProbe: 39 | tcpSocket: 40 | port: 6379 41 | ports: 42 | - name: redis-server 43 | containerPort: 6379 44 | -------------------------------------------------------------------------------- /jdk-example/kubernetes-latest/meeting-deployment-latest.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: extensions/v1beta1 16 | kind: Deployment 17 | metadata: 18 | name: meeting-server-latest 19 | labels: 20 | app: meeting-server 21 | version: latest 22 | visualize: "true" 23 | spec: 24 | replicas: 2 25 | template: 26 | metadata: 27 | labels: 28 | app: meeting-server 29 | serving: "true" 30 | version: latest 31 | visualize: "true" 32 | spec: 33 | serviceAccountName: meeting-server 34 | containers: 35 | - name: meeting-server 36 | image: saturnism/meeting-server-istio:latest 37 | ports: 38 | - containerPort: 8081 39 | name: http 40 | -------------------------------------------------------------------------------- /jdk-example/work-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.example.istio 8 | work-server 9 | 1.0-SNAPSHOT 10 | A fun example using libraries available in the JDK. 11 | 12 | com.example.istio 13 | jdk-example 14 | 1.0-SNAPSHOT 15 | ../pom.xml 16 | 17 | 18 | com.example.jdk.WorkServer 19 | 20 | 21 | 22 | 23 | com.google.cloud.tools 24 | jib-maven-plugin 25 | 26 | 27 | com.spotify 28 | dockerfile-maven-plugin 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /jdk-example/kubernetes-v1/work-deployment-v1.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: extensions/v1beta1 16 | kind: Deployment 17 | metadata: 18 | name: work-server-v1 19 | labels: 20 | app: work-server 21 | version: "1.0" 22 | visualize: "true" 23 | spec: 24 | replicas: 2 25 | template: 26 | metadata: 27 | labels: 28 | app: work-server 29 | serving: "true" 30 | version: "1.0" 31 | visualize: "true" 32 | spec: 33 | containers: 34 | - name: work-server 35 | image: saturnism/work-server-istio:v1 36 | env: 37 | - name: ENDPOINT 38 | value: http://meeting-server:8081/meet 39 | ports: 40 | - containerPort: 8080 41 | name: http 42 | -------------------------------------------------------------------------------- /jdk-example/meeting-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.example.istio 8 | meeting-server 9 | 1.0-SNAPSHOT 10 | A fun example using libraries available in the JDK. 11 | 12 | com.example.istio 13 | jdk-example 14 | 1.0-SNAPSHOT 15 | ../pom.xml 16 | 17 | 18 | com.example.jdk.MeetingServer 19 | 20 | 21 | 22 | 23 | com.google.cloud.tools 24 | jib-maven-plugin 25 | 26 | 27 | com.spotify 28 | dockerfile-maven-plugin 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /spring-boot-example/guestbook-service/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # TODO: High-level file comment. 16 | 17 | spring: 18 | application: 19 | name: guestbook-service 20 | rest: 21 | base-path: /api 22 | datasource: 23 | driverClassName: com.mysql.jdbc.Driver 24 | url: jdbc:mysql://mysql:3306/app?autoReconnect=true 25 | username: root 26 | password: yourpassword 27 | test-on-borrow: true 28 | validation-query: SELECT 1 29 | jpa: 30 | database-platform: org.hibernate.dialect.MySQL5Dialect 31 | hibernate: 32 | generate-ddl: true 33 | ddl-auto: update 34 | globally_quoted_identifiers: true 35 | sleuth: 36 | propagation-keys: x-request-id,x-ot-span-context 37 | -------------------------------------------------------------------------------- /jdk-example/kubernetes-v2/work-deployment-v2.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: extensions/v1beta1 16 | kind: Deployment 17 | metadata: 18 | name: work-server-v2 19 | labels: 20 | app: work-server 21 | version: "2.0" 22 | visualize: "true" 23 | spec: 24 | replicas: 2 25 | template: 26 | metadata: 27 | labels: 28 | app: work-server 29 | serving: "true" 30 | version: "2.0" 31 | visualize: "true" 32 | spec: 33 | serviceAccountName: work-server 34 | containers: 35 | - name: work-server 36 | image: saturnism/work-server-istio:v2 37 | env: 38 | - name: ENDPOINT 39 | value: http://meeting-server:8081/meet 40 | ports: 41 | - containerPort: 8080 42 | name: http 43 | -------------------------------------------------------------------------------- /jdk-example/kubernetes-latest/work-deployment-latest.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: extensions/v1beta1 16 | kind: Deployment 17 | metadata: 18 | name: work-server-latest 19 | labels: 20 | app: work-server 21 | version: latest 22 | visualize: "true" 23 | spec: 24 | replicas: 2 25 | template: 26 | metadata: 27 | labels: 28 | app: work-server 29 | serving: "true" 30 | version: latest 31 | visualize: "true" 32 | spec: 33 | serviceAccountName: work-server 34 | containers: 35 | - name: work-server 36 | image: saturnism/work-server-istio:latest 37 | env: 38 | - name: ENDPOINT 39 | value: http://meeting-server:8081/meet 40 | ports: 41 | - containerPort: 8080 42 | name: http 43 | -------------------------------------------------------------------------------- /visualizer/index.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 23 | 24 | 25 | 26 | 27 |
28 | 36 |
37 |
38 |
39 | 40 | 41 | -------------------------------------------------------------------------------- /spring-boot-example/README.md: -------------------------------------------------------------------------------- 1 | ## Deploy Application to Kubernetes 2 | Check out the example code: 3 | ``` 4 | $ cd ~/ 5 | $ git clone https://github.com/saturnism/istio-by-example-java.git 6 | $ cd istio-by-example-java/spring-boot-example 7 | ``` 8 | 9 | Deploy the application: 10 | ``` 11 | $ kubectl apply -f kubernetes/ 12 | ``` 13 | 14 | Notice that the YAML files are just regular Kubernetes deployment YAML. This is because Istio 0.2+ can use Kubernetes initializer feature. 15 | During deployment time, Kubernetes will automatically & transparently inject additional sidecars and configurations to these YAML files. 16 | 17 | ## Addons 18 | ### Grafana 19 | Establish port forward from local port 3000 to the Grafana instance: 20 | ``` 21 | $ kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=grafana -o jsonpath='{.items[0].metadata.name}') 3000:3000 22 | ``` 23 | 24 | Browse to http://localhost:3000 and navigate to Istio Dashboard 25 | 26 | ### Zipkin 27 | Establish port forward from local port 28 | ``` 29 | $ kubectl port-forward -n istio-system $(kubectl get pod -n istio-system -l app=zipkin -o jsonpath='{.items[0].metadata.name}') 9411:9411 30 | ``` 31 | 32 | Browse to http://localhost:9411 33 | 34 | ### Prometheus 35 | ``` 36 | $ kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=prometheus -o jsonpath='{.items[0].metadata.name}') 9090:9090 37 | ``` 38 | 39 | ### Service Graph 40 | ``` 41 | $ kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=servicegraph -o jsonpath='{.items[0].metadata.name}') 8088:8088 42 | ``` 43 | 44 | Browse to http://localhost:8088/dotviz 45 | -------------------------------------------------------------------------------- /jdk-example/meeting-server/src/main/java/com/example/jdk/MeetingServer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.example.jdk; 17 | 18 | import com.sun.net.httpserver.HttpServer; 19 | 20 | import java.io.IOException; 21 | import java.io.OutputStream; 22 | import java.net.InetAddress; 23 | import java.net.InetSocketAddress; 24 | import java.nio.charset.StandardCharsets; 25 | import java.util.concurrent.Executors; 26 | import java.util.concurrent.ThreadLocalRandom; 27 | 28 | public class MeetingServer { 29 | public static void main(String[] args) throws IOException { 30 | HttpServer server = HttpServer.create(new InetSocketAddress(8081), 0); 31 | server.setExecutor(Executors.newCachedThreadPool()); 32 | 33 | server.createContext("/meet", exchange -> { 34 | try { 35 | Thread.sleep(250); 36 | } catch (InterruptedException e) { 37 | } 38 | 39 | exchange.sendResponseHeaders(200, 0); 40 | exchange.getResponseBody().close(); 41 | }); 42 | 43 | server.start(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes/guestbook-deployment-v1.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: apps/v1 16 | kind: Deployment 17 | metadata: 18 | name: guestbook-service-v1 19 | labels: 20 | app: guestbook-service 21 | version: "1.0" 22 | visualize: "true" 23 | spec: 24 | replicas: 2 25 | selector: 26 | matchLabels: 27 | app: guestbook-service 28 | version: "1.0" 29 | serving: "true" 30 | template: 31 | metadata: 32 | labels: 33 | app: guestbook-service 34 | serving: "true" 35 | version: "1.0" 36 | visualize: "true" 37 | spec: 38 | containers: 39 | - name: guestbook-service 40 | image: saturnism/guestbook-service-istio:1.0 41 | livenessProbe: 42 | initialDelaySeconds: 90 43 | httpGet: 44 | path: /actuator/health 45 | port: 8080 46 | readinessProbe: 47 | httpGet: 48 | path: / 49 | port: 8080 50 | ports: 51 | - containerPort: 8080 52 | name: http 53 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes/helloworld-deployment-v1.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: apps/v1 16 | kind: Deployment 17 | metadata: 18 | name: helloworld-service-v1 19 | labels: 20 | app: helloworld-service 21 | version: "1.0" 22 | visualize: "true" 23 | spec: 24 | replicas: 2 25 | selector: 26 | matchLabels: 27 | app: helloworld-service 28 | version: "1.0" 29 | serving: "true" 30 | template: 31 | metadata: 32 | labels: 33 | app: helloworld-service 34 | version: "1.0" 35 | serving: "true" 36 | visualize: "true" 37 | spec: 38 | containers: 39 | - name: helloworld-service 40 | image: saturnism/helloworld-service-istio:1.0 41 | livenessProbe: 42 | initialDelaySeconds: 60 43 | httpGet: 44 | path: /actuator/health 45 | port: 8080 46 | readinessProbe: 47 | httpGet: 48 | path: /hello/ready 49 | port: 8080 50 | ports: 51 | - name: http 52 | containerPort: 8080 53 | -------------------------------------------------------------------------------- /spring-boot-example/guestbook-service/src/main/java/com/example/guestbook/MessageService.java: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // TODO: High-level file comment. 16 | 17 | /* 18 | * Copyright 2015 Google Inc. All Rights Reserved. 19 | * 20 | * Licensed under the Apache License, Version 2.0 (the "License"); 21 | * you may not use this file except in compliance with the License. 22 | * You may obtain a copy of the License at 23 | * 24 | * http://www.apache.org/licenses/LICENSE-2.0 25 | * 26 | * Unless required by applicable law or agreed to in writing, software 27 | * distributed under the License is distributed on an "AS IS" BASIS, 28 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 29 | * See the License for the specific language governing permissions and 30 | * limitations under the License. 31 | */ 32 | package com.example.guestbook; 33 | 34 | import org.springframework.data.repository.PagingAndSortingRepository; 35 | import org.springframework.data.rest.core.annotation.RepositoryRestResource; 36 | 37 | /** 38 | * Created by rayt on 5/1/17. 39 | */ 40 | @RepositoryRestResource 41 | public interface MessageService extends PagingAndSortingRepository { 42 | } 43 | -------------------------------------------------------------------------------- /spring-boot-example/guestbook-ui/src/main/java/com/example/guestbook/HelloworldUiApplication.java: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // TODO: High-level file comment. 16 | 17 | /* 18 | * Copyright 2015 Google Inc. All Rights Reserved. 19 | * 20 | * Licensed under the Apache License, Version 2.0 (the "License"); 21 | * you may not use this file except in compliance with the License. 22 | * You may obtain a copy of the License at 23 | * 24 | * http://www.apache.org/licenses/LICENSE-2.0 25 | * 26 | * Unless required by applicable law or agreed to in writing, software 27 | * distributed under the License is distributed on an "AS IS" BASIS, 28 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 29 | * See the License for the specific language governing permissions and 30 | * limitations under the License. 31 | */ 32 | package com.example.guestbook; 33 | 34 | import org.springframework.boot.SpringApplication; 35 | import org.springframework.boot.autoconfigure.SpringBootApplication; 36 | 37 | @SpringBootApplication 38 | public class HelloworldUiApplication { 39 | 40 | public static void main(String[] args) { 41 | SpringApplication.run(HelloworldUiApplication.class, args); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes-mtls/guestbook-deployment-v1.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: apps/v1 16 | kind: Deployment 17 | metadata: 18 | name: guestbook-service-v1 19 | labels: 20 | app: guestbook-service 21 | version: "1.0" 22 | visualize: "true" 23 | spec: 24 | replicas: 2 25 | selector: 26 | matchLabels: 27 | app: guestbook-service 28 | version: "1.0" 29 | serving: "true" 30 | template: 31 | metadata: 32 | labels: 33 | app: guestbook-service 34 | serving: "true" 35 | version: "1.0" 36 | visualize: "true" 37 | spec: 38 | serviceAccountName: guestbook-service 39 | containers: 40 | - name: guestbook-service 41 | image: saturnism/guestbook-service-istio:1.0 42 | livenessProbe: 43 | initialDelaySeconds: 90 44 | exec: 45 | command: 46 | - wget 47 | - -qO- 48 | - http://localhost:8080/actuator/health 49 | readinessProbe: 50 | exec: 51 | command: 52 | - wget 53 | - -qO- 54 | - http://localhost:8080/ 55 | ports: 56 | - containerPort: 8080 57 | name: http 58 | -------------------------------------------------------------------------------- /spring-boot-example/guestbook-service/src/main/java/com/example/guestbook/GuestbookServiceApplication.java: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // TODO: High-level file comment. 16 | 17 | /* 18 | * Copyright 2015 Google Inc. All Rights Reserved. 19 | * 20 | * Licensed under the Apache License, Version 2.0 (the "License"); 21 | * you may not use this file except in compliance with the License. 22 | * You may obtain a copy of the License at 23 | * 24 | * http://www.apache.org/licenses/LICENSE-2.0 25 | * 26 | * Unless required by applicable law or agreed to in writing, software 27 | * distributed under the License is distributed on an "AS IS" BASIS, 28 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 29 | * See the License for the specific language governing permissions and 30 | * limitations under the License. 31 | */ 32 | package com.example.guestbook; 33 | 34 | import org.springframework.boot.SpringApplication; 35 | import org.springframework.boot.autoconfigure.SpringBootApplication; 36 | 37 | @SpringBootApplication 38 | public class GuestbookServiceApplication { 39 | 40 | public static void main(String[] args) { 41 | SpringApplication.run(GuestbookServiceApplication.class, args); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes/mysql-deployment.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: apps/v1 16 | kind: Deployment 17 | metadata: 18 | name: mysql 19 | labels: 20 | app: mysql 21 | visualize: "true" 22 | spec: 23 | replicas: 1 24 | selector: 25 | matchLabels: 26 | app: mysql 27 | version: "5.6" 28 | template: 29 | metadata: 30 | labels: 31 | app: mysql 32 | version: "5.6" 33 | visualize: "true" 34 | spec: 35 | containers: 36 | - name: mysql 37 | image: mysql:5.6 38 | livenessProbe: 39 | tcpSocket: 40 | port: 3306 41 | env: 42 | - name: MYSQL_ROOT_PASSWORD 43 | # change this 44 | value: yourpassword 45 | - name: MYSQL_DATABASE 46 | value: app 47 | ports: 48 | - containerPort: 3306 49 | name: mysql 50 | volumeMounts: 51 | # name must match the volume name below 52 | - name: mysql-persistent-storage 53 | # mount path within the container 54 | mountPath: /var/lib/mysql 55 | volumes: 56 | - name: mysql-persistent-storage 57 | persistentVolumeClaim: 58 | claimName: mysql-pvc 59 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes-mtls/mysql-deployment.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: apps/v1 16 | kind: Deployment 17 | metadata: 18 | name: mysql 19 | labels: 20 | app: mysql 21 | visualize: "true" 22 | spec: 23 | replicas: 1 24 | selector: 25 | matchLabels: 26 | app: mysql 27 | version: "5.6" 28 | template: 29 | metadata: 30 | labels: 31 | app: mysql 32 | version: "5.6" 33 | visualize: "true" 34 | spec: 35 | containers: 36 | - name: mysql 37 | image: mysql:5.6 38 | livenessProbe: 39 | tcpSocket: 40 | port: 3306 41 | env: 42 | - name: MYSQL_ROOT_PASSWORD 43 | # change this 44 | value: yourpassword 45 | - name: MYSQL_DATABASE 46 | value: app 47 | ports: 48 | - containerPort: 3306 49 | name: mysql 50 | volumeMounts: 51 | # name must match the volume name below 52 | - name: mysql-persistent-storage 53 | # mount path within the container 54 | mountPath: /var/lib/mysql 55 | volumes: 56 | - name: mysql-persistent-storage 57 | persistentVolumeClaim: 58 | claimName: mysql-pvc 59 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes-v2/ui-deployment-v2.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: apps/v1 16 | kind: Deployment 17 | metadata: 18 | name: guestbook-ui-v2 19 | labels: 20 | app: guestbook-ui 21 | version: "2.0" 22 | visualize: "true" 23 | spec: 24 | replicas: 2 25 | selector: 26 | matchLabels: 27 | app: guestbook-ui 28 | version: "2.0" 29 | serving: "true" 30 | template: 31 | metadata: 32 | labels: 33 | app: guestbook-ui 34 | version: "2.0" 35 | serving: "true" 36 | visualize: "true" 37 | annotations: 38 | visualizer/uses: helloworld-service,guestbook-service,redis 39 | spec: 40 | containers: 41 | - name: guestbook-ui 42 | image: saturnism/guestbook-ui-istio:2.0 43 | env: 44 | - name: BACKEND_GUESTBOOK_SERVICE_URL 45 | value: http://guestbook-service/messages 46 | livenessProbe: 47 | initialDelaySeconds: 60 48 | httpGet: 49 | path: /actuator/health 50 | port: 8080 51 | readinessProbe: 52 | httpGet: 53 | path: / 54 | port: 8080 55 | ports: 56 | - name: http 57 | containerPort: 8080 58 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes/ui-deployment-v1.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: apps/v1 16 | kind: Deployment 17 | metadata: 18 | name: guestbook-ui-v1 19 | labels: 20 | app: guestbook-ui 21 | version: "1.0" 22 | visualize: "true" 23 | spec: 24 | replicas: 2 25 | selector: 26 | matchLabels: 27 | app: guestbook-ui 28 | version: "1.0" 29 | serving: "true" 30 | template: 31 | metadata: 32 | labels: 33 | app: guestbook-ui 34 | version: "1.0" 35 | serving: "true" 36 | visualize: "true" 37 | annotations: 38 | visualizer/uses: helloworld-service,guestbook-service,redis 39 | spec: 40 | containers: 41 | - name: guestbook-ui 42 | image: saturnism/guestbook-ui-istio:1.0 43 | env: 44 | - name: BACKEND_GUESTBOOK_SERVICE_URL 45 | value: http://guestbook-service/messages 46 | livenessProbe: 47 | initialDelaySeconds: 60 48 | httpGet: 49 | path: /actuator/health 50 | port: 8080 51 | readinessProbe: 52 | httpGet: 53 | path: / 54 | port: 8080 55 | ports: 56 | - name: http 57 | containerPort: 8080 58 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes-mtls/helloworld-deployment-v1.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: apps/v1 16 | kind: Deployment 17 | metadata: 18 | name: helloworld-service-v1 19 | labels: 20 | app: helloworld-service 21 | version: "1.0" 22 | visualize: "true" 23 | spec: 24 | replicas: 2 25 | selector: 26 | matchLabels: 27 | app: helloworld-service 28 | version: "1.0" 29 | serving: "true" 30 | template: 31 | metadata: 32 | labels: 33 | app: helloworld-service 34 | version: "1.0" 35 | serving: "true" 36 | visualize: "true" 37 | spec: 38 | serviceAccount: helloworld-service 39 | containers: 40 | - name: helloworld-service 41 | image: saturnism/helloworld-service-istio:1.0 42 | livenessProbe: 43 | initialDelaySeconds: 60 44 | exec: 45 | command: 46 | - wget 47 | - -qO- 48 | - http://localhost:8080/actuator/health 49 | readinessProbe: 50 | exec: 51 | command: 52 | - wget 53 | - -qO- 54 | - http://localhost:8080/hello/ready 55 | ports: 56 | - name: http 57 | containerPort: 8080 58 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes-v2/helloworld-deployment-v2.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: apps/v1 16 | kind: Deployment 17 | metadata: 18 | name: helloworld-service-v2 19 | labels: 20 | app: helloworld-service 21 | version: "2.0" 22 | visualize: "true" 23 | spec: 24 | replicas: 2 25 | selector: 26 | matchLabels: 27 | app: helloworld-service 28 | version: "2.0" 29 | serving: "true" 30 | template: 31 | metadata: 32 | labels: 33 | app: helloworld-service 34 | version: "2.0" 35 | serving: "true" 36 | visualize: "true" 37 | spec: 38 | containers: 39 | - name: helloworld-service 40 | image: saturnism/helloworld-service-istio:1.0 41 | env: 42 | - name: VERSION 43 | value: "2.0" 44 | - name: GREETING 45 | value: "Hola $name from $hostname version $version" 46 | livenessProbe: 47 | initialDelaySeconds: 60 48 | httpGet: 49 | path: /actuator/health 50 | port: 8080 51 | readinessProbe: 52 | httpGet: 53 | path: /hello/ready 54 | port: 8080 55 | ports: 56 | - name: http 57 | containerPort: 8080 58 | -------------------------------------------------------------------------------- /spring-boot-example/work-server/src/main/java/com/example/workserver/WorkServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.workserver; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.boot.SpringApplication; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.http.HttpStatus; 11 | import org.springframework.http.ResponseEntity; 12 | import org.springframework.web.bind.annotation.GetMapping; 13 | import org.springframework.web.bind.annotation.RestController; 14 | import org.springframework.web.client.RestTemplate; 15 | 16 | import java.net.URI; 17 | 18 | @SpringBootApplication 19 | public class WorkServerApplication { 20 | 21 | @Bean 22 | public RestTemplate restTemplate() { 23 | return new RestTemplate(); 24 | } 25 | 26 | public static void main(String[] args) { 27 | SpringApplication.run(WorkServerApplication.class, args); 28 | } 29 | 30 | @RestController 31 | public static class WorkController { 32 | private static Logger logger = LoggerFactory.getLogger(WorkController.class); 33 | 34 | @Value("${endpoint:http://localhost:8081/meet}") 35 | private String endpoint; 36 | 37 | @Autowired 38 | private RestTemplate restTemplate; 39 | 40 | 41 | @GetMapping("/work") 42 | public String work() { 43 | int count = 0; 44 | for (int i = 0; i < 4; i++) { 45 | logger.info("Going to meeting: {}", i); 46 | ResponseEntity entity = restTemplate 47 | .getForEntity(URI.create(endpoint), Void.class); 48 | if (entity.getStatusCode() == HttpStatus.OK) { 49 | count++; 50 | } 51 | } 52 | 53 | return "went to " + count + " meetings"; 54 | } 55 | 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes-mtls/ui-deployment-v1.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: apps/v1 16 | kind: Deployment 17 | metadata: 18 | name: guestbook-ui-v1 19 | labels: 20 | app: guestbook-ui 21 | version: "1.0" 22 | visualize: "true" 23 | spec: 24 | replicas: 2 25 | selector: 26 | matchLabels: 27 | app: guestbook-ui 28 | version: "1.0" 29 | serving: "true" 30 | template: 31 | metadata: 32 | labels: 33 | app: guestbook-ui 34 | version: "1.0" 35 | serving: "true" 36 | visualize: "true" 37 | annotations: 38 | visualizer/uses: helloworld-service,guestbook-service,redis 39 | spec: 40 | serviceAccount: guestbook-ui 41 | containers: 42 | - name: guestbook-ui 43 | image: saturnism/guestbook-ui-istio:1.0 44 | env: 45 | - name: BACKEND_GUESTBOOK_SERVICE_URL 46 | value: http://guestbook-service/messages 47 | livenessProbe: 48 | initialDelaySeconds: 60 49 | exec: 50 | command: 51 | - wget 52 | - -qO- 53 | - http://localhost:8080/actuator/health 54 | readinessProbe: 55 | exec: 56 | command: 57 | - wget 58 | - -qO- 59 | - http://localhost:8080/ 60 | ports: 61 | - name: http 62 | containerPort: 8080 63 | -------------------------------------------------------------------------------- /spring-boot-example/kubernetes-mtls/ui-deployment-v2.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: apps/v1 16 | kind: Deployment 17 | metadata: 18 | name: guestbook-ui-v2 19 | labels: 20 | app: guestbook-ui 21 | version: "2.0" 22 | visualize: "true" 23 | spec: 24 | replicas: 2 25 | selector: 26 | matchLabels: 27 | app: guestbook-ui 28 | version: "2.0" 29 | serving: "true" 30 | template: 31 | metadata: 32 | labels: 33 | app: guestbook-ui 34 | version: "2.0" 35 | serving: "true" 36 | visualize: "true" 37 | annotations: 38 | visualizer/uses: helloworld-service,guestbook-service,redis 39 | spec: 40 | serviceAccount: guestbook-ui 41 | containers: 42 | - name: guestbook-ui 43 | image: saturnism/guestbook-ui-istio:2.0 44 | env: 45 | - name: BACKEND_GUESTBOOK_SERVICE_URL 46 | value: http://guestbook-service/messages 47 | livenessProbe: 48 | initialDelaySeconds: 60 49 | exec: 50 | command: 51 | - wget 52 | - -qO- 53 | - http://localhost:8080/actuator/health 54 | readinessProbe: 55 | exec: 56 | command: 57 | - wget 58 | - -qO- 59 | - http://localhost:8080/ 60 | ports: 61 | - name: http 62 | containerPort: 8080 63 | -------------------------------------------------------------------------------- /visualizer/script.js: -------------------------------------------------------------------------------- 1 | jQuery(document).ready(function($) { 2 | var graph_url = '/api/v1/namespaces/istio-system/services/servicegraph:http/proxy/graph?time_horizon=30s&filter_empty=true'; 3 | 4 | var sankey_options = { 5 | animation: { 6 | startup: true, 7 | duration: 100, 8 | easing: 'out' 9 | }, 10 | sankey: { 11 | link: { 12 | color: { 13 | fill: '#D4EAF6' 14 | } 15 | }, 16 | node: { 17 | colors: [ '#a6cee3' ], 18 | width: 12, 19 | nodePadding: 10, 20 | label: { 21 | fontSize: 12, 22 | color: '#4C84A2' 23 | } 24 | } 25 | } 26 | }; 27 | 28 | function setup() { 29 | } 30 | 31 | function refresh() { 32 | var chart = new google.visualization.Sankey(document.getElementById('sankey')); 33 | var request = $.getJSON(graph_url, function(data) { 34 | if (!data || !data.edges) return; 35 | 36 | var table = new google.visualization.DataTable(); 37 | 38 | table.addColumn('string', 'Source'); 39 | table.addColumn('string', 'Destination'); 40 | table.addColumn('number', 'RPS'); 41 | 42 | var rows = data.edges 43 | .filter(e => !e.source.startsWith('unknown')) 44 | // .filter(e => !e.source.startsWith('ingress.istio-system')) 45 | .filter(e => !isNaN(e.labels['reqs/sec'])) 46 | .map(function(e) { 47 | return [e.source, e.target, Number(e.labels['reqs/sec'])]; 48 | // return [e.source, e.target, 1]; 49 | }) 50 | .filter(e => e[2] > 0); 51 | 52 | if (rows && rows.length > 0) { 53 | table.addRows(rows); 54 | table.sort([{column: 0}, {column: 1}]); 55 | chart.draw(table, sankey_options); 56 | } 57 | console.log(rows); 58 | 59 | }); 60 | 61 | $.when(request).then(function() { 62 | setTimeout(refresh, 1000); 63 | }); 64 | } 65 | 66 | google.charts.load('current', {'packages':['sankey']}); 67 | google.charts.setOnLoadCallback(refresh); 68 | setup(); 69 | }); 70 | -------------------------------------------------------------------------------- /spring-boot-example/guestbook-ui/src/main/java/com/example/guestbook/ApplicationConfig.java: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // TODO: High-level file comment. 16 | 17 | /* 18 | * Copyright 2015 Google Inc. All Rights Reserved. 19 | * 20 | * Licensed under the Apache License, Version 2.0 (the "License"); 21 | * you may not use this file except in compliance with the License. 22 | * You may obtain a copy of the License at 23 | * 24 | * http://www.apache.org/licenses/LICENSE-2.0 25 | * 26 | * Unless required by applicable law or agreed to in writing, software 27 | * distributed under the License is distributed on an "AS IS" BASIS, 28 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 29 | * See the License for the specific language governing permissions and 30 | * limitations under the License. 31 | */ 32 | package com.example.guestbook; 33 | 34 | import org.springframework.beans.factory.annotation.Value; 35 | import org.springframework.context.annotation.Bean; 36 | import org.springframework.context.annotation.Configuration; 37 | import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession; 38 | import org.springframework.web.client.RestTemplate; 39 | 40 | /** 41 | * Created by rayt on 5/1/17. 42 | */ 43 | @Configuration 44 | @EnableRedisHttpSession 45 | public class ApplicationConfig { 46 | @Bean 47 | RestTemplate restTemplate() { 48 | RestTemplate restTemplate = new RestTemplate(); 49 | return restTemplate; 50 | } 51 | 52 | @Bean 53 | HelloworldService helloworldService(RestTemplate restTemplate, @Value("${backend.helloworld-service.url}") String endpoint) { 54 | return new HelloworldService(restTemplate, endpoint); 55 | } 56 | 57 | @Bean 58 | GuestbookService guestbookService(RestTemplate restTemplate, @Value("${backend.guestbook-service.url}") String endpoint) { 59 | return new GuestbookService(restTemplate, endpoint); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /spring-boot-example/guestbook-service/src/main/java/com/example/guestbook/Message.java: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // TODO: High-level file comment. 16 | 17 | /* 18 | * Copyright 2015 Google Inc. All Rights Reserved. 19 | * 20 | * Licensed under the Apache License, Version 2.0 (the "License"); 21 | * you may not use this file except in compliance with the License. 22 | * You may obtain a copy of the License at 23 | * 24 | * http://www.apache.org/licenses/LICENSE-2.0 25 | * 26 | * Unless required by applicable law or agreed to in writing, software 27 | * distributed under the License is distributed on an "AS IS" BASIS, 28 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 29 | * See the License for the specific language governing permissions and 30 | * limitations under the License. 31 | */ 32 | package com.example.guestbook; 33 | 34 | import javax.persistence.Entity; 35 | import javax.persistence.GeneratedValue; 36 | import javax.persistence.GenerationType; 37 | import javax.persistence.Id; 38 | import java.io.Serializable; 39 | import java.util.Date; 40 | 41 | /** 42 | * Created by rayt on 5/1/17. 43 | */ 44 | @Entity 45 | public class Message implements Serializable { 46 | @Id 47 | @GeneratedValue(strategy = GenerationType.IDENTITY) 48 | private Long id; 49 | 50 | private String username; 51 | private String message; 52 | private Date timestamp; 53 | 54 | public Long getId() { 55 | return id; 56 | } 57 | 58 | public void setId(Long id) { 59 | this.id = id; 60 | } 61 | 62 | public String getUsername() { 63 | return username; 64 | } 65 | 66 | public void setUsername(String username) { 67 | this.username = username; 68 | } 69 | 70 | public String getMessage() { 71 | return message; 72 | } 73 | 74 | public void setMessage(String message) { 75 | this.message = message; 76 | } 77 | 78 | public Date getTimestamp() { 79 | return timestamp; 80 | } 81 | 82 | public void setTimestamp(Date timestamp) { 83 | this.timestamp = timestamp; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /spring-boot-example/guestbook-ui/src/main/java/com/example/guestbook/HelloworldUiController.java: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // TODO: High-level file comment. 16 | 17 | /* 18 | * Copyright 2015 Google Inc. All Rights Reserved. 19 | * 20 | * Licensed under the Apache License, Version 2.0 (the "License"); 21 | * you may not use this file except in compliance with the License. 22 | * You may obtain a copy of the License at 23 | * 24 | * http://www.apache.org/licenses/LICENSE-2.0 25 | * 26 | * Unless required by applicable law or agreed to in writing, software 27 | * distributed under the License is distributed on an "AS IS" BASIS, 28 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 29 | * See the License for the specific language governing permissions and 30 | * limitations under the License. 31 | */ 32 | package com.example.guestbook; 33 | 34 | import org.springframework.stereotype.Controller; 35 | import org.springframework.ui.Model; 36 | import org.springframework.web.bind.annotation.*; 37 | import org.springframework.web.context.annotation.SessionScope; 38 | 39 | import java.util.Map; 40 | 41 | /** 42 | * Created by rayt on 5/1/17. 43 | */ 44 | @Controller 45 | @SessionAttributes("name") 46 | public class HelloworldUiController { 47 | private final HelloworldService helloworldService; 48 | private final GuestbookService guestbookService; 49 | 50 | public HelloworldUiController(HelloworldService helloworldService, GuestbookService guestbookService) { 51 | this.helloworldService = helloworldService; 52 | this.guestbookService = guestbookService; 53 | } 54 | 55 | @GetMapping("/") 56 | public String index(Model model) { 57 | if (model.containsAttribute("name")) { 58 | String name = (String) model.asMap().get("name"); 59 | Map greeting = helloworldService.greeting(name); 60 | model.addAttribute("greeting", greeting); 61 | } 62 | 63 | model.addAttribute("messages", guestbookService.all()); 64 | 65 | return "index"; 66 | } 67 | 68 | @PostMapping("/greet") 69 | public String greet(@RequestParam String name, @RequestParam String message, Model model) { 70 | model.addAttribute("name", name); 71 | if (message != null && !message.trim().isEmpty()) { 72 | guestbookService.add(name, message); 73 | } 74 | 75 | return "redirect:/"; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /spring-boot-example/guestbook-ui/src/main/java/com/example/guestbook/HelloworldService.java: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // TODO: High-level file comment. 16 | 17 | /* 18 | * Copyright 2015 Google Inc. All Rights Reserved. 19 | * 20 | * Licensed under the Apache License, Version 2.0 (the "License"); 21 | * you may not use this file except in compliance with the License. 22 | * You may obtain a copy of the License at 23 | * 24 | * http://www.apache.org/licenses/LICENSE-2.0 25 | * 26 | * Unless required by applicable law or agreed to in writing, software 27 | * distributed under the License is distributed on an "AS IS" BASIS, 28 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 29 | * See the License for the specific language governing permissions and 30 | * limitations under the License. 31 | */ 32 | package com.example.guestbook; 33 | 34 | import io.github.resilience4j.bulkhead.Bulkhead; 35 | import org.apache.commons.logging.Log; 36 | import org.apache.commons.logging.LogFactory; 37 | import org.springframework.http.HttpStatus; 38 | import org.springframework.http.client.ClientHttpResponse; 39 | import org.springframework.web.client.HttpStatusCodeException; 40 | import org.springframework.web.client.ResponseErrorHandler; 41 | import org.springframework.web.client.RestTemplate; 42 | 43 | import java.io.IOException; 44 | import java.util.HashMap; 45 | import java.util.Map; 46 | import java.util.function.Supplier; 47 | 48 | /** 49 | * Created by rayt on 5/1/17. 50 | */ 51 | public class HelloworldService { 52 | private final static Log log = LogFactory.getLog(HelloworldService.class); 53 | private final RestTemplate restTemplate; 54 | private final String endpoint; 55 | 56 | public HelloworldService(RestTemplate restTemplate, String endpoint) { 57 | this.restTemplate = restTemplate; 58 | this.endpoint = endpoint; 59 | } 60 | 61 | public Map greetingFallback() { 62 | Map response = new HashMap<>(); 63 | response.put("greeting", "Unable to connect"); 64 | return response; 65 | } 66 | 67 | public Map greeting(String name) { 68 | try { 69 | return restTemplate.getForObject(endpoint + "/" + name, Map.class); 70 | } catch (HttpStatusCodeException e) { 71 | log.error("Error from Helloworld Service, falling back", e); 72 | return greetingFallback(); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /spring-boot-example/helloworld-service/src/main/java/com/example/guestbook/HelloworldApplication.java: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // TODO: High-level file comment. 16 | 17 | /* 18 | * Copyright 2015 Google Inc. All Rights Reserved. 19 | * 20 | * Licensed under the Apache License, Version 2.0 (the "License"); 21 | * you may not use this file except in compliance with the License. 22 | * You may obtain a copy of the License at 23 | * 24 | * http://www.apache.org/licenses/LICENSE-2.0 25 | * 26 | * Unless required by applicable law or agreed to in writing, software 27 | * distributed under the License is distributed on an "AS IS" BASIS, 28 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 29 | * See the License for the specific language governing permissions and 30 | * limitations under the License. 31 | */ 32 | package com.example.guestbook; 33 | 34 | import org.slf4j.Logger; 35 | import org.slf4j.LoggerFactory; 36 | import org.springframework.beans.factory.annotation.Value; 37 | import org.springframework.boot.SpringApplication; 38 | import org.springframework.boot.autoconfigure.SpringBootApplication; 39 | import org.springframework.web.bind.annotation.GetMapping; 40 | import org.springframework.web.bind.annotation.PathVariable; 41 | import org.springframework.web.bind.annotation.RestController; 42 | 43 | import java.net.InetAddress; 44 | import java.net.UnknownHostException; 45 | import java.util.HashMap; 46 | import java.util.Map; 47 | 48 | @SpringBootApplication 49 | public class HelloworldApplication { 50 | public static void main(String[] args) { 51 | SpringApplication.run(HelloworldApplication.class, args); 52 | } 53 | } 54 | 55 | @RestController 56 | class HelloworldController { 57 | private static final Logger log = LoggerFactory.getLogger(HelloworldController.class); 58 | 59 | @Value("${version:1.0}") 60 | public String version; 61 | 62 | @GetMapping("/hello/{name}") 63 | public Map hello(@Value("${greeting}") String greetingTemplate, @PathVariable String name) throws UnknownHostException { 64 | log.info("Recevied hello request for: " + name); 65 | Map response = new HashMap<>(); 66 | 67 | String hostname = InetAddress.getLocalHost().getHostName(); 68 | String greeting = greetingTemplate 69 | .replaceAll("\\$name", name) 70 | .replaceAll("\\$hostname", hostname) 71 | .replaceAll("\\$version", version); 72 | 73 | response.put("greeting", greeting); 74 | response.put("version", version); 75 | response.put("hostname", hostname); 76 | 77 | return response; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /jdk-example/work-server/src/main/java/com/example/jdk/WorkServer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.example.jdk; 17 | 18 | import com.sun.net.httpserver.HttpServer; 19 | import jdk.incubator.http.HttpClient; 20 | import jdk.incubator.http.HttpRequest; 21 | import jdk.incubator.http.HttpResponse; 22 | 23 | import java.io.IOException; 24 | import java.io.OutputStream; 25 | import java.net.InetAddress; 26 | import java.net.InetSocketAddress; 27 | import java.net.URI; 28 | import java.nio.charset.StandardCharsets; 29 | import java.util.Arrays; 30 | import java.util.concurrent.Executors; 31 | 32 | public class WorkServer { 33 | static final String[] TRACE_HEADERS = new String[] {"x-request-id", "x-b3-traceid", "x-b3-spanid", "x-b3-parentspanid", "x-b3-sampled", "x-b3-flags", "x-ot-span-context"}; 34 | 35 | public static void main(String[] args) throws IOException { 36 | String endpoint = System.getenv().getOrDefault("ENDPOINT", "http://localhost:8081/meet"); 37 | HttpServer server = HttpServer.create(new InetSocketAddress(8080), 0); 38 | server.setExecutor(Executors.newCachedThreadPool()); 39 | String hostName = InetAddress.getLocalHost().getHostName(); 40 | 41 | server.createContext("/work", exchange -> { 42 | long start = System.currentTimeMillis(); 43 | 44 | HttpClient httpClient = HttpClient.newHttpClient(); 45 | HttpRequest.Builder builder = HttpRequest.newBuilder(URI.create(endpoint)).GET() 46 | .version(HttpClient.Version.HTTP_1_1) 47 | .setHeader("User-Agent", "Java/9"); 48 | 49 | Arrays.stream(TRACE_HEADERS).forEach(header -> { 50 | String value = exchange.getRequestHeaders().getFirst(header); 51 | if (value != null) { 52 | builder.header(header, value); 53 | } 54 | }); 55 | 56 | HttpRequest request = builder.build(); 57 | 58 | int meetings = 0; 59 | for (int i = 0; i < 8; i++) { 60 | try { 61 | HttpResponse response = httpClient.send(request, HttpResponse.BodyHandler.asString()); 62 | if (response.statusCode() == 200) { 63 | meetings++; 64 | } 65 | } catch (InterruptedException e) { 66 | } 67 | } 68 | 69 | long end = System.currentTimeMillis(); 70 | 71 | String response = "Working REALLY HARD for " + (end - start) + "ms, attended " + meetings + " meetings at " + hostName + "\n"; 72 | byte[] bytes = response.getBytes(StandardCharsets.UTF_8); 73 | exchange.sendResponseHeaders(200, bytes.length); 74 | OutputStream os = exchange.getResponseBody(); 75 | 76 | os.write(bytes); 77 | os.close(); 78 | }); 79 | 80 | server.start(); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /spring-boot-example/work-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.example 7 | work-server 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | work-server 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.0.2.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | Finchley.RELEASE 26 | saturnism 27 | 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-web 33 | 34 | 35 | org.springframework.cloud 36 | spring-cloud-starter-sleuth 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-starter-test 42 | test 43 | 44 | 45 | 46 | 47 | 48 | 49 | org.springframework.cloud 50 | spring-cloud-dependencies 51 | ${spring-cloud.version} 52 | pom 53 | import 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | org.springframework.boot 62 | spring-boot-maven-plugin 63 | 64 | 65 | com.spotify 66 | dockerfile-maven-plugin 67 | 1.3.6 68 | 69 | ${docker.image.prefix}/${project.artifactId}-istio 70 | latest 71 | 72 | 73 | 74 | package 75 | 76 | build 77 | push 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | spring-snapshots 88 | Spring Snapshots 89 | https://repo.spring.io/snapshot 90 | 91 | true 92 | 93 | 94 | 95 | spring-milestones 96 | Spring Milestones 97 | https://repo.spring.io/milestone 98 | 99 | false 100 | 101 | 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /spring-boot-example/meeting-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.example 7 | meeting-server 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | meeting-server 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.0.2.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | Finchley.RELEASE 26 | saturnism 27 | 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-web 33 | 34 | 35 | org.springframework.cloud 36 | spring-cloud-starter-sleuth 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-starter-test 42 | test 43 | 44 | 45 | 46 | 47 | 48 | 49 | org.springframework.cloud 50 | spring-cloud-dependencies 51 | ${spring-cloud.version} 52 | pom 53 | import 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | org.springframework.boot 62 | spring-boot-maven-plugin 63 | 64 | 65 | com.spotify 66 | dockerfile-maven-plugin 67 | 1.3.6 68 | 69 | ${docker.image.prefix}/${project.artifactId}-istio 70 | latest 71 | 72 | 73 | 74 | package 75 | 76 | build 77 | push 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | spring-snapshots 88 | Spring Snapshots 89 | https://repo.spring.io/snapshot 90 | 91 | true 92 | 93 | 94 | 95 | spring-milestones 96 | Spring Milestones 97 | https://repo.spring.io/milestone 98 | 99 | false 100 | 101 | 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /spring-boot-example/guestbook-ui/src/main/resources/templates/index.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | Hello World Guestbook 19 | 20 | 21 | 22 | 32 | 33 | 34 | 52 | 53 |
54 |
55 |
56 | Your name: 57 | Message: 58 | 59 |
60 |
61 | 62 |
63 | Greeting 64 |
65 | 66 |
67 |
68 | Username 69 | Message 70 |
71 |
72 | 73 |
74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /spring-boot-example/helloworld-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 4.0.0 20 | 21 | com.example.guestbook 22 | helloworld-service 23 | 0.0.1-SNAPSHOT 24 | jar 25 | 26 | helloworld-service 27 | Demo project for Spring Boot 28 | 29 | 30 | com.example.guestbook 31 | spring-boot2-example 32 | 0.0.1-SNAPSHOT 33 | 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-web 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-starter-actuator 43 | 44 | 45 | org.springframework.cloud 46 | spring-cloud-starter-sleuth 47 | 48 | 49 | org.springframework.boot 50 | spring-boot-starter-test 51 | test 52 | 53 | 54 | 55 | 56 | 57 | 58 | org.springframework.cloud 59 | spring-cloud-dependencies 60 | ${spring-cloud.version} 61 | pom 62 | import 63 | 64 | 65 | 66 | 67 | 68 | 69 | 75 | 76 | maven-jar-plugin 77 | 78 | 79 | 80 | true 81 | lib/ 82 | com.example.guestbook.HelloworldApplication 83 | 84 | 85 | 86 | 87 | 88 | maven-dependency-plugin 89 | 90 | 91 | com.spotify 92 | dockerfile-maven-plugin 93 | 94 | 95 | pl.project13.maven 96 | git-commit-id-plugin 97 | 98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /spring-boot-example/guestbook-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 4.0.0 20 | 21 | com.example.guestbook 22 | guestbook-service 23 | 0.0.1-SNAPSHOT 24 | jar 25 | 26 | guestbook-service 27 | Demo project for Spring Boot 28 | 29 | 30 | com.example.guestbook 31 | spring-boot2-example 32 | 0.0.1-SNAPSHOT 33 | 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-actuator 39 | 40 | 41 | org.springframework.cloud 42 | spring-cloud-starter-sleuth 43 | 44 | 45 | org.springframework.boot 46 | spring-boot-starter-data-jpa 47 | 48 | 49 | org.springframework.boot 50 | spring-boot-starter-data-rest 51 | 52 | 53 | mysql 54 | mysql-connector-java 55 | 56 | 57 | org.springframework.boot 58 | spring-boot-starter-test 59 | test 60 | 61 | 62 | 63 | 64 | 65 | 66 | org.springframework.cloud 67 | spring-cloud-dependencies 68 | ${spring-cloud.version} 69 | pom 70 | import 71 | 72 | 73 | 74 | 75 | 76 | 77 | 83 | 84 | maven-jar-plugin 85 | 86 | 87 | 88 | true 89 | lib/ 90 | com.example.guestbook.GuestbookServiceApplication 91 | 92 | 93 | 94 | 95 | 96 | maven-dependency-plugin 97 | 98 | 99 | com.spotify 100 | dockerfile-maven-plugin 101 | 102 | 103 | pl.project13.maven 104 | git-commit-id-plugin 105 | 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /jdk-example/README.md: -------------------------------------------------------------------------------- 1 | ## Setup a Kubernetes cluster on Google Cloud Platform 2 | 3 | You'll need a [Google Cloud Platform account](https://cloud.google.com/), a [Project](https://cloud.google.com/resource-manager/docs/creating-managing-projects), and [gcloud SDK](https://cloud.google.com/sdk/). 4 | 5 | First, create a new Kubernetes cluster with alpha features to take advantage of Kubernetes initializer. 6 | ``` 7 | $ export ISTIO_PROJECT_ID=$(gcloud config get-value core/project) 8 | $ gcloud --project=$ISTIO_PROJECT_ID alpha container clusters create istio-cluster \ 9 | --zone=us-central1-c --num-nodes=4 --machine-type=n1-standard-4 \ 10 | --cluster-version=1.7.8-gke.0 --enable-kubernetes-alpha 11 | ``` 12 | 13 | Once the cluster was created, make sure your user account has admin role within the Kubernetes cluster: 14 | ``` 15 | $ kubectl create clusterrolebinding cluster-admin-binding --clusterrole=cluster-admin \ 16 | --user=$(gcloud config get-value core/account) 17 | ``` 18 | 19 | ## Install Istio 20 | 21 | Install Istio CLI: 22 | ``` 23 | $ cd ~/ 24 | $ curl -L https://git.io/getLatestIstio | sh - 25 | $ export PATH="$PATH:$HOME/istio-0.2.7/bin" 26 | ``` 27 | 28 | Install Istio Service Mesh in Kubernetes: 29 | ``` 30 | $ cd ~/istio-0.2.7 31 | $ kubectl apply -f install/kubernetes/istio-auth.yaml 32 | $ kubectl apply -f install/kubernetes/istio-initializer.yaml 33 | ``` 34 | 35 | Install Add-ons for Grafana, Prometheus, and Zipkin: 36 | ``` 37 | $ cd ~/istio-0.2.7 38 | $ kubectl apply -f install/kubernetes/addons/zipkin.yaml 39 | $ kubectl apply -f install/kubernetes/addons/grafana.yaml 40 | $ kubectl apply -f install/kubernetes/addons/prometheus.yaml 41 | $ kubectl apply -f install/kubernetes/addons/servicegraph.yaml 42 | ``` 43 | 44 | Check the status and make sure all the components are in running state before continuing: 45 | ``` 46 | $ kubectl get pods -n istio-system 47 | ``` 48 | 49 | Enable firewall to allow connection to the Istio ingress: 50 | ``` 51 | $ gcloud --project=$ISTIO_PROJECT_ID compute firewall-rules create allow-istio-ingress \ 52 | --allow tcp:$(kubectl get svc istio-ingress -n istio-system -o jsonpath='{.spec.ports[0].nodePort}') 53 | ``` 54 | 55 | ## Deploy Application to Kubernetes 56 | Check out the example code: 57 | ``` 58 | $ cd ~/ 59 | $ git clone https://github.com/saturnism/istio-by-example-java.git 60 | $ cd istio-by-example-java/jdk-example 61 | ``` 62 | 63 | Deploy the application: 64 | ``` 65 | $ kubectl apply -f kubernetes/ 66 | ``` 67 | 68 | Notice that the YAML files are just regular Kubernetes deployment YAML. This is because Istio 0.2+ can use Kubernetes initializer feature. 69 | During deployment time, Kubernetes will automatically & transparently inject additional sidecars and configurations to these YAML files. 70 | 71 | ## Addons 72 | ### Grafana 73 | Establish port forward from local port 3000 to the Grafana instance: 74 | ``` 75 | $ kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=grafana \ 76 | -o jsonpath='{.items[0].metadata.name}') 3000:3000 77 | ``` 78 | 79 | Browse to http://localhost:3000 and navigate to Istio Dashboard 80 | 81 | ### Zipkin 82 | Establish port forward from local port 83 | ``` 84 | $ kubectl port-forward -n istio-system \ 85 | $(kubectl get pod -n istio-system -l app=zipkin -o jsonpath='{.items[0].metadata.name}') \ 86 | 9411:9411 87 | ``` 88 | 89 | Browse to http://localhost:9411 90 | 91 | ### Prometheus 92 | ``` 93 | $ kubectl -n istio-system port-forward \ 94 | $(kubectl -n istio-system get pod -l app=prometheus -o jsonpath='{.items[0].metadata.name}') \ 95 | 9090:9090 96 | ``` 97 | 98 | ### Service Graph 99 | ``` 100 | $ kubectl -n istio-system port-forward \ 101 | $(kubectl -n istio-system get pod -l app=servicegraph -o jsonpath='{.items[0].metadata.name}') \ 102 | 8088:8088 103 | ``` 104 | 105 | Browse to http://localhost:8088/dotviz 106 | -------------------------------------------------------------------------------- /spring-boot-example/guestbook-ui/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 4.0.0 20 | 21 | com.example.guestbook 22 | guestbook-ui 23 | 0.0.1-SNAPSHOT 24 | jar 25 | 26 | guestbook-ui 27 | Demo project for Spring Boot 28 | 29 | 30 | com.example.guestbook 31 | spring-boot2-example 32 | 0.0.1-SNAPSHOT 33 | 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-actuator 39 | 40 | 41 | org.springframework.cloud 42 | spring-cloud-starter-sleuth 43 | 44 | 45 | io.github.resilience4j 46 | resilience4j-bulkhead 47 | 0.10.0 48 | 49 | 50 | org.springframework.boot 51 | spring-boot-starter-thymeleaf 52 | 53 | 54 | org.springframework.boot 55 | spring-boot-starter-web 56 | 57 | 58 | org.springframework.boot 59 | spring-boot-starter-data-redis 60 | 61 | 62 | org.springframework.session 63 | spring-session-data-redis 64 | 65 | 66 | org.springframework.boot 67 | spring-boot-starter-test 68 | test 69 | 70 | 71 | 72 | 73 | 74 | 75 | org.springframework.cloud 76 | spring-cloud-dependencies 77 | ${spring-cloud.version} 78 | pom 79 | import 80 | 81 | 82 | 83 | 84 | 85 | 86 | 92 | 93 | maven-jar-plugin 94 | 95 | 96 | 97 | true 98 | lib/ 99 | com.example.guestbook.HelloworldUiApplication 100 | 101 | 102 | 103 | 104 | 105 | maven-dependency-plugin 106 | 107 | 108 | com.spotify 109 | dockerfile-maven-plugin 110 | 111 | 112 | pl.project13.maven 113 | git-commit-id-plugin 114 | 115 | 116 | 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /spring-boot-example/guestbook-ui/src/main/java/com/example/guestbook/GuestbookService.java: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // TODO: High-level file comment. 16 | 17 | /* 18 | * Copyright 2015 Google Inc. All Rights Reserved. 19 | * 20 | * Licensed under the Apache License, Version 2.0 (the "License"); 21 | * you may not use this file except in compliance with the License. 22 | * You may obtain a copy of the License at 23 | * 24 | * http://www.apache.org/licenses/LICENSE-2.0 25 | * 26 | * Unless required by applicable law or agreed to in writing, software 27 | * distributed under the License is distributed on an "AS IS" BASIS, 28 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 29 | * See the License for the specific language governing permissions and 30 | * limitations under the License. 31 | */ 32 | package com.example.guestbook; 33 | 34 | import io.vavr.control.Try; 35 | import org.apache.commons.logging.Log; 36 | import org.apache.commons.logging.LogFactory; 37 | import org.slf4j.LoggerFactory; 38 | import org.springframework.http.HttpStatus; 39 | import org.springframework.web.client.HttpStatusCodeException; 40 | import org.springframework.web.client.RestTemplate; 41 | 42 | import java.text.DateFormat; 43 | import java.text.SimpleDateFormat; 44 | import java.util.*; 45 | import java.util.stream.Collectors; 46 | 47 | /** 48 | * Created by rayt on 5/1/17. 49 | */ 50 | public class GuestbookService { 51 | private static final Log log = LogFactory.getLog(GuestbookService.class); 52 | private final RestTemplate restTemplate; 53 | private final String endpoint; 54 | private final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); 55 | 56 | public GuestbookService(RestTemplate restTemplate, String endpoint) { 57 | this.restTemplate = restTemplate; 58 | this.endpoint = endpoint; 59 | } 60 | 61 | public Map add(String username, String message) { 62 | Map payload = new HashMap<>(); 63 | payload.put("username", username); 64 | payload.put("message", message); 65 | payload.put("timestamp", dateFormat.format(new Date())); 66 | 67 | // Istio can handle circuit breaking. Don't need to retry here. 68 | return restTemplate.postForObject(endpoint, payload, Map.class); 69 | } 70 | 71 | public List allFallback() { 72 | Map bulkheadEntry = new HashMap<>(); 73 | bulkheadEntry.put("username", "system"); 74 | bulkheadEntry.put("message", "Guestbook Service is currently unavailable"); 75 | return Arrays.asList(bulkheadEntry); 76 | } 77 | 78 | public List all() { 79 | try { 80 | Map response = restTemplate.getForObject(endpoint, Map.class); 81 | 82 | Map embedded = (Map) response.get("_embedded"); 83 | List messages = (List) embedded.get("messages"); 84 | return messages.stream() 85 | .filter(message -> message.containsKey("_links")) 86 | .map(message -> (Map) message.get("_links")) 87 | .filter(links -> links.containsKey("self")) 88 | .map(links -> (Map) links.get("self")) 89 | .map(self -> (String) self.get("href")) 90 | .map(href -> restTemplate.getForObject(href, Map.class)) 91 | .collect(Collectors.toList()); 92 | } catch (HttpStatusCodeException e) { 93 | // Istio would've performed circuit breaking and retries 94 | // but it doesn't handle bulkheads / returning default values on full failures. 95 | log.error("Error from Guestbook Service, falling back", e); 96 | return allFallback(); 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /spring-boot-example/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 4.0.0 20 | 21 | com.example.guestbook 22 | spring-boot2-example 23 | 0.0.1-SNAPSHOT 24 | pom 25 | 26 | guestbook-example 27 | Demo project for Spring Boot 2 and Istio 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-parent 32 | 2.0.3.RELEASE 33 | 34 | 35 | 36 | 37 | UTF-8 38 | UTF-8 39 | 1.8 40 | Finchley.RELEASE 41 | saturnism 42 | 43 | 44 | 45 | 46 | 47 | 48 | maven-jar-plugin 49 | 50 | 51 | 52 | true 53 | lib/ 54 | 55 | 56 | 57 | 58 | 59 | maven-dependency-plugin 60 | 61 | 62 | initialize 63 | 64 | copy-dependencies 65 | 66 | 67 | false 68 | runtime 69 | ${project.build.directory}/lib 70 | 71 | 72 | 73 | 74 | 75 | com.spotify 76 | dockerfile-maven-plugin 77 | 1.3.5 78 | 79 | ${docker.image.prefix}/${project.artifactId}-istio 80 | latest 81 | 82 | 83 | 84 | package 85 | 86 | build 87 | 88 | 89 | 90 | 91 | 92 | pl.project13.maven 93 | git-commit-id-plugin 94 | 2.1.15 95 | 96 | 97 | 98 | revision 99 | 100 | 101 | 102 | 103 | ${project.basedir}/.git 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | spring-milestones 113 | Spring Milestones 114 | http://repo.spring.io/milestone 115 | 116 | false 117 | 118 | 119 | 120 | 121 | 122 | helloworld-service 123 | guestbook-service 124 | guestbook-ui 125 | work-server 126 | meeting-server 127 | 128 | 129 | -------------------------------------------------------------------------------- /jdk-example/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.example.istio 8 | jdk-example 9 | 1.0-SNAPSHOT 10 | pom 11 | A fun example using libraries available in the JDK. 12 | 13 | work-server 14 | meeting-server 15 | 16 | 17 | 18 | saturnism 19 | 9 20 | 9 21 | 22 | 23 | 24 | 25 | 26 | org.apache.maven.plugins 27 | maven-compiler-plugin 28 | 3.8.0 29 | 30 | 9 31 | 9 32 | 33 | 34 | 35 | maven-jar-plugin 36 | 37 | 38 | 39 | ${main.class} 40 | 41 | 42 | 43 | 44 | 45 | com.google.cloud.tools 46 | jib-maven-plugin 47 | 0.9.11 48 | 49 | 50 | adoptopenjdk/openjdk11-openj9:jdk-11.28 51 | 52 | 53 | ${docker.image.prefix}/${project.artifactId}-istio 54 | 55 | 56 | 57 | 58 | com.spotify 59 | dockerfile-maven-plugin 60 | 1.3.6 61 | 62 | ${docker.image.prefix}/${project.artifactId}-istio 63 | latest 64 | 65 | 66 | 67 | package 68 | 69 | build 70 | push 71 | 72 | 73 | 74 | 75 | 76 | org.codehaus.plexus 77 | plexus-archiver 78 | 3.4 79 | 80 | 81 | javax.activation 82 | javax.activation-api 83 | 1.2.0 84 | 85 | 86 | 87 | 88 | pl.project13.maven 89 | git-commit-id-plugin 90 | 2.1.15 91 | 92 | 93 | 94 | revision 95 | 96 | 97 | 98 | 99 | ${project.basedir}/.git 100 | 101 | 102 | 103 | 104 | 105 | 106 | org.apache.maven.plugins 107 | maven-compiler-plugin 108 | 109 | 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /spring-boot-example/meeting-server/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 84 | @REM Fallback to current working directory if not found. 85 | 86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 88 | 89 | set EXEC_DIR=%CD% 90 | set WDIR=%EXEC_DIR% 91 | :findBaseDir 92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 93 | cd .. 94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 95 | set WDIR=%CD% 96 | goto findBaseDir 97 | 98 | :baseDirFound 99 | set MAVEN_PROJECTBASEDIR=%WDIR% 100 | cd "%EXEC_DIR%" 101 | goto endDetectBaseDir 102 | 103 | :baseDirNotFound 104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 105 | cd "%EXEC_DIR%" 106 | 107 | :endDetectBaseDir 108 | 109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 110 | 111 | @setlocal EnableExtensions EnableDelayedExpansion 112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 114 | 115 | :endReadAdditionalConfig 116 | 117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 118 | 119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 121 | 122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 123 | if ERRORLEVEL 1 goto error 124 | goto end 125 | 126 | :error 127 | set ERROR_CODE=1 128 | 129 | :end 130 | @endlocal & set ERROR_CODE=%ERROR_CODE% 131 | 132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 136 | :skipRcPost 137 | 138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 140 | 141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 142 | 143 | exit /B %ERROR_CODE% 144 | -------------------------------------------------------------------------------- /spring-boot-example/work-server/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 84 | @REM Fallback to current working directory if not found. 85 | 86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 88 | 89 | set EXEC_DIR=%CD% 90 | set WDIR=%EXEC_DIR% 91 | :findBaseDir 92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 93 | cd .. 94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 95 | set WDIR=%CD% 96 | goto findBaseDir 97 | 98 | :baseDirFound 99 | set MAVEN_PROJECTBASEDIR=%WDIR% 100 | cd "%EXEC_DIR%" 101 | goto endDetectBaseDir 102 | 103 | :baseDirNotFound 104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 105 | cd "%EXEC_DIR%" 106 | 107 | :endDetectBaseDir 108 | 109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 110 | 111 | @setlocal EnableExtensions EnableDelayedExpansion 112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 114 | 115 | :endReadAdditionalConfig 116 | 117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 118 | 119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 121 | 122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 123 | if ERRORLEVEL 1 goto error 124 | goto end 125 | 126 | :error 127 | set ERROR_CODE=1 128 | 129 | :end 130 | @endlocal & set ERROR_CODE=%ERROR_CODE% 131 | 132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 136 | :skipRcPost 137 | 138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 140 | 141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 142 | 143 | exit /B %ERROR_CODE% 144 | -------------------------------------------------------------------------------- /spring-boot-example/work-server/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Migwn, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 204 | echo $MAVEN_PROJECTBASEDIR 205 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 206 | 207 | # For Cygwin, switch paths to Windows format before running java 208 | if $cygwin; then 209 | [ -n "$M2_HOME" ] && 210 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 211 | [ -n "$JAVA_HOME" ] && 212 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 213 | [ -n "$CLASSPATH" ] && 214 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 215 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 216 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 217 | fi 218 | 219 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 220 | 221 | exec "$JAVACMD" \ 222 | $MAVEN_OPTS \ 223 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 224 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 225 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 226 | -------------------------------------------------------------------------------- /spring-boot-example/meeting-server/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Migwn, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 204 | echo $MAVEN_PROJECTBASEDIR 205 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 206 | 207 | # For Cygwin, switch paths to Windows format before running java 208 | if $cygwin; then 209 | [ -n "$M2_HOME" ] && 210 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 211 | [ -n "$JAVA_HOME" ] && 212 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 213 | [ -n "$CLASSPATH" ] && 214 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 215 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 216 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 217 | fi 218 | 219 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 220 | 221 | exec "$JAVACMD" \ 222 | $MAVEN_OPTS \ 223 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 224 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 225 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 226 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /visualizer/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | --------------------------------------------------------------------------------