Giter Club home page Giter Club logo

pcc-sample-app-pizzastore's Introduction

Example Spring Boot Application for VMware Tanzu GemFire For VMs

This versioned example app for VMware Tanzu GemFire is a Spring Boot app that can be used with a Tanzu GemFire service instance. This branch demonstrates deployment scenarios for an app, and how the app's location affects communication with a Tanzu GemFire For VMs service instance. Branches of this git repository correspond to the Tanzu GemFire version that this app will work with. Check out and run the app from the branch that matches your Tanzu GemFire tile version. For example, if your Tanzu GemFire service instance is version 2.1, check out this repository's release/2.1 branch.

The app uses Spring Boot for Apache Geode (SBDG) to talk to the Tanzu GemFire service instance. The app provides a REST interface that lets a user view pizzas, place orders, and view an order. The app leverages Spring Web MVC controllers to expose data access operations.

Pizzas are stored in the Tanzu GemFire servers running within the Tanzu GemFire service instance. The app uses a Spring Data Repository to store, access, and query data stored on the servers. The app stores data in the Pizza repository (repositories are referred to as regions in Tanzu GemFire). See GemFire Basics for the briefest of introductions to Tanzu GemFire, and see Region Design for a quick tour of Tanzu GemFire regions.

Interacting With the App

The app talks to a Tanzu GemFire service instance. The app does create, read, and delete CRUD operations on data held in a region within service instance.

The app exposes these endpoints:

  • https://APP-URL/

    Prints the available app endpoints.

  • https://APP-URL/ping

    Prints PONG! if the app is running.

  • https://APP-URL/preheatOven

    Creates three pre-defined pizzas, which adds them to the region.

  • https://APP-URL/pizzas

    Gets all pizzas from the region.

  • https://APP-URL/pizzas/{name}

    Gets details of a pizza specified by its name.

  • https://APP-URL/pizzas/order/{name}

    Orders a given pizza, which does a create operation. For example: https://APP-URL/pizzas/order/myCustomPizza?sauce=MARINARA&toppings=CHEESE,PEPPERONI,MUSHROOM orders a pizza named myCustomPizza, which has MARINARA sauce and three toppings.

  • https://APP-URL/cleanSlate

    Deletes all pizzas from the region.

Prerequisites

  • The cf CLI will be used.
  • Log in to your CF (TAS) environment.
  • The CF (TAS) environment should have a Tanzu GemFire for VMs Tile installed.

App Location

An app that uses a Tanzu GemFire service instance may be located in one of three locations, as specified in The App's Location. This app demonstrates all three possibilities of app location using Spring profiles.

In addition, the app may be run locally, without having a Geode or Tanzu GemFire service instance. All four running environments are described.

Run the App in a Local Environment

This Spring Boot app can run locally, without having an Apache Geode or Tanzu GemFire service instance. Uncomment the annotation @EnableClusterAware in the app's source file src/main/java/io/pivotal/cloudcache/app/config/PizzaConfig.java to enable redirecting cache operations operations to LOCAL regions when there is no service instance to talk to. It implements an embedded cache on the client.

To run the app in the local environment,

$ ./mvnw spring-boot:run

Ignore the ConnectException: Connection refused from the root of this repository.

Use the running app:

Use a web browser to talk to the app at http://localhost:8080.

Run the App in the Same Foundation as the Service Instance (Services Foundation App)

When the app and the service instance are in the same foundation, SBDG eliminates the need to do any security configuration. Credentials and TLS configurations are auto applied.

Run the app as a services foundation app:
  1. Make note of the SERVICE-INSTANCE-NAME when you Create a Service Instance. The service instance may be TLS-enabled or not TLS-enabled.

  2. Modify the manifest.yml file to provide the service instance name. Replace SERVICE_INSTANCE with your noted SERVICE-INSTANCE-NAME. Remove the # character so that the line is no longer a comment.

  3. Build the app:

    $ ./mvnw clean install
    
  4. With a current working directory of PCC-Sample-App-PizzaStore, push the app to your services foundation with a cf push command. Note the app's route (APP-URL).

Use the running app:

Interact with the running app by hitting the endpoints exposed by the app.

You can use gfsh to inspect the service instance. Follow the instructions in Accessing a Service Instance to connect to the cluster using gfsh.

Run the App in an App Foundation

Running an app foundation app requires a service gateway. To set up a service gateway, follow the directions in Configure a Service Gateway.

Run the app as an app foundation app:

  1. Make note of the SERVICE-INSTANCE-NAME when you Create a Service Instance. Provide the optional parameters for enabling TLS and specifying the creation of a service gateway.

  2. Follow these instructions to Create Truststore for the App. Note the password you set for the truststore.

  3. Copy the truststore to the resources directory within the app source code.

  4. Follow these instructions to Create a Service Key.

  5. Edit the app's src/main/resources/application-app-foundation.properties file, and specify the properties described in Specifying Application Properties. Find the values needed in the service key and the truststore.

  6. Edit the app's manifest_app_foundation.yml file to specify the truststore password noted when you created the truststore.

  7. Build the app:

    $ ./mvnw clean install
    
  8. Do a cf login that targets the app foundation's org and space. With a current working directory of PCC-Sample-App-PizzaStore, push the app to the app foundation, specifying the manifest:

    $ cf push -f manifest_app_foundation.yml
    

    Note the app's route (APP-URL).

Use the running app:

Interact with the running app by hitting the endpoints exposed by the app.

Run the App Off Platform

Running an app that is not on any Cloud Foundry foundation requires a service gateway. To set up a service gateway, follow the directions in Configure a Service Gateway.

Run the app locally, and not on any foundation:

  1. Make note of the SERVICE-INSTANCE-NAME when you Create a Service Instance. Provide the optional parameters for enabling TLS and specifying the creation of a service gateway.

  2. Follow these instructions to Create Truststore for the App. Note the password you set for the truststore.

  3. Copy the truststore to the resources directory within the app source code.

  4. Follow these instructions to Create a Service Key.

  5. Edit the app's src/main/resources/application-off-platform.properties file, and specify the properties described in Specifying Application Properties. Find the values needed in the service key and the truststore.

  6. Build the app:

    $ ./mvnw clean install
    
  7. Run the app locally:

    $ ./mvnw spring-boot:run -Dspring-boot.run.profiles=off-platform -Dspring-boot.run.jvmArguments="-Djavax.net.ssl.trustStore=/tmp/mytruststore1.jks -Djavax.net.ssl.trustStorePassword=PASSWD-HERE"
    

    replacing PASSWD-HERE with the truststore password noted when you created the truststore.

Use the running app:

Interact with the running app by hitting the endpoints exposed by the app at http://localhost:8080.

pcc-sample-app-pizzastore's People

Contributors

davebarnes97 avatar davidjahn avatar dependabot[bot] avatar ebeer avatar h4xnoodle avatar julianbenitez99 avatar jxblum avatar matthewfischer avatar pdxrunner avatar pnikonowicz avatar pulkit-chandra avatar reneighbor avatar rishipathak10 avatar srikanthmanvi avatar taylorsilva avatar vfordpivotal avatar waciumawanjohi avatar yuniersoad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pcc-sample-app-pizzastore's Issues

Create a POM file for maven compatiblity

WHY: A lot of developers still work with maven and would prefer to work with it.

What: We should provide a pom file on the project which is in sync with gradle so that developers could easily work with project.

IllegalStateException: No service with tags [cloudcache, gemfire] was found

Error Log Below :

2019-01-24T09:05:55.87-0500 [CELL/0] OUT Cell e750e5e7-b64b-4303-90fb-87b993b1e102 successfully created container for instance 1a3d5c8f-cbca-4ca8-769f-46d0
2019-01-24T09:05:58.79-0500 [CELL/0] OUT Starting health monitoring of container
2019-01-24T09:05:59.16-0500 [APP/PROC/WEB/0] OUT JVM Memory Configuration: -Xmx375814K -Xss1M -XX:ReservedCodeCacheSize=240M -XX:MaxDirectMemorySize=10M -XX:MaxMetaspaceSize=160761K
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT [error 2019/01/24 14:06:10.056 UTC

tid=0x1] Application run failed
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT java.lang.IllegalStateException: No service with tags [cloudcache, gemfire] was found
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at org.springframework.data.gemfire.util.RuntimeExceptionFactory.newIllegalStateException(RuntimeExceptionFactory.java:91)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at org.springframework.data.gemfire.util.RuntimeExceptionFactory.newIllegalStateException(RuntimeExceptionFactory.java:77)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at org.springframework.geode.core.env.VcapPropertySource.lambda$findFirstCloudCacheServiceName$21(VcapPropertySource.java:196)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at java.util.Optional.orElseThrow(Optional.java:290)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at org.springframework.geode.core.env.VcapPropertySource.findFirstCloudCacheServiceName(VcapPropertySource.java:195)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at org.springframework.geode.core.env.VcapPropertySource.findFirstCloudCacheService(VcapPropertySource.java:167)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at org.springframework.geode.boot.autoconfigure.ClientSecurityAutoConfiguration$AutoConfiguredCloudSecurityEnvironmentPostProcessor.configureSecurityContext(ClientSecurityAutoConfiguration.java:164)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at java.util.Optional.ifPresent(Optional.java:159)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at org.springframework.geode.boot.autoconfigure.ClientSecurityAutoConfiguration$AutoConfiguredCloudSecurityEnvironmentPostProcessor.postProcessEnvironment(ClientSecurityAutoConfiguration.java:108)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:185)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:171)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:338)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at org.springframework.boot.SpringApplication.run(SpringApplication.java:297)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at org.springframework.boot.SpringApplication.run(SpringApplication.java:1242)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at org.springframework.boot.SpringApplication.run(SpringApplication.java:1230)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at io.pivotal.cloudcache.app.CloudcachePizzaStoreApplication.main(CloudcachePizzaStoreApplication.java:37)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at java.lang.reflect.Method.invoke(Method.java:498)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
2019-01-24T09:06:10.06-0500 [APP/PROC/WEB/0] OUT at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
2019-01-24T09:06:10.25-0500 [APP/PROC/WEB/0] OUT Exit status 1

Please configure GITBOT

Pivotal provides the Gitbot service to synchronize issues and pull requests made against public GitHub repos with Pivotal Tracker projects.

If you do not want to use Pivotal Tracker to manage this GitHub repo, you do not need to take any action.

If you are a Pivotal employee, you can configure Gitbot to sync your GitHub repo to your Pivotal Tracker project with a pull request.

Steps:

  • Fork this repo: cfgitbot-config (an ask+cf@ ticket is the fastest way to get read access if you get a 404)
  • Add the Toolsmiths-Bots team to have admin access to your repo
  • Add the cf-gitbot ([email protected]) user to have owner access to your Pivotal Tracker project
  • Add your new repo and or project to config-production.yml file
  • Submit a PR, which will get auto-merged if you've done it right

If you are not a pivotal employee, you can request that [email protected] set up the integration for you.

You might also be interested in configuring GitHub's Service Hook for Tracker on your repo so you can link your commits to Tracker stories. You can do this yourself by following the directions at:

https://www.pivotaltracker.com/blog/guide-githubs-service-hook-tracker/

If there are any questions, please reach out to [email protected].

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.