Code Monkey home page Code Monkey logo

infinispan-embedded-tutorial's Introduction

Infinispan Embedded Tutorial: Weather App

Overview

This is a tutorial which explains how to use Infinispan embedded in your own application. The application will retrieve the current weather conditions for some cities and store them in a cache, for quicker retrieval. It will also show how to configure the cache for expiration, so that entries get removed as they age. It will then demonstrate how to cluster multiple nodes together and reacting to events in the cluster. Finally, a computation of average temperatures per country will show the power of the map/reduce functionality.

Each tagged commit is a separate lesson teaching a single aspect of Infinispan.

The tutorial instructions are at http://infinispan.org/tutorials/embedded/

N.B. The tutorial connects to OpenWeatherMap (http://openweathermap.org) to retrieve current weather data. The service requires obtaining a free API key. Before launching the application, ensure you've set the OWMAPIKEY environment variable to your API key. If you don't want to register for the service, if you don't have an Internet connection or you are having trouble connecting to the service, just don't set the environment variable, and it will use the RandomWeatherService.

Prerequisites

Git

  • A good place to learn about setting up git is here
  • Git home (download, documentation)

JDK

  • Get a JDK. You will need version 1.8 or higher

Maven

  • Get Maven. You will need version 3.2 or higher

Commits / Tutorial Outline

You can check out any point of the tutorial using git checkout step-?

To see the changes between any two lessons use the git diff command. git diff step-?..step-?

step-0/setup

  • The initial implementation of the Weather application

step-1/cache-manager

  • Adding Infinispan to the project and initializing a cache manager

step-2/cache-put-get

  • Add caching to the weather service

step-3/expiration

  • Store the entries in the cache with an expiration time

step-4/cachemanager-configuration

  • Configure the features of the default cache

step-5/clustering

  • Add a transport to the CacheManager so that it supports clustering

step-6/cachemanager-listener

  • Use CacheManager events to detect changes in the cluster

step-7/cache-listener

  • Detect changes to the cache with a clustered listener

step-8/grouping

  • Group related entries on the same nodes for efficiency

step-9/externalizer

  • Implement a custom externalizer for our value class

step-10/streams

  • Use Distributed Streams to compute temperature averages per country

step-11/declarative-configuration

  • Use the XML configuration instead of the programmatic API

Building and running the tutorial

  • Run mvn clean package to rebuild the application
  • Run mvn exec:exec to execute the application. In case you're running a clustered step, run this from multiple terminals, where each instance will represent a node

Application Directory Layout

src/                -->
  main/             -->
    java/           -->
    resources/      -->

Contact

For more information on Infinispan please check out http://infinispan.org/

infinispan-embedded-tutorial's People

Contributors

tristantarrant avatar wburns avatar

Watchers

James Cloos avatar Felipe Moraes avatar

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.