Giter Club home page Giter Club logo

hazelcast-entrylistener-handoff's Introduction

Hazelcast EntryListener Hand Off

Introduction

Hazelcast EntryListener are used to react to events that occur on Maps. An EntryListener is a callback interface that a developer can implement to execute their code in reaction to a Map Event, such as Update, Add, Delete.

Internally EntryListeners are called via the internal hazelcast event thread pool. The event thread pool is described here

In general it is considered bad practice to have long running code hanging off these threads and inside the EntryListeners. If your code runs for too long or gets into a deadlock situation then events that are waiting behind will delay or in the worst case eventually get lost as there is no more room on the event queue.

EntryListener Hand Off

This project is a framework that introduces the concept of handing off event processing from the internal hazelcast event threads and onto a thread pool that is more clearly controlled by the developer. In a nutshell it does exactly as the name describes. It takes events from the event callback and then places them into a new thread pool.

EntryEventService

The Framework resides around the central concept of an EntryEventService. The EntryEventService is responsible for processing the EntryEvent that are passed to EntryListeners.

The EntryEventService has one method called process. This method takes the EntryEvent passed by Hazelcast and a CompletionListener

The EntryEventService is responsible for examining the EntryEvent and processing it appropriately. Some implementations may make use of the EntryEventTypeProcessorFactory. This Factory provides an EntryEventProcessor per EntryEventType.

EntryEventService

ThreadPoolEntryEventService

There is currently one implementation of an EntryEventService, called the ThreadPoolEntryEventService, it provide the following features :-

  1. ThreadPoolEntryEventService provides a striped set of ThreadPoolExecutors that guarantees execution order by key.
  2. A Warning Service to inform of long running EntryEventTypeProcessors
  3. CompletionService callback to inform of failed/completed processes
  4. Getter to retrieve the striped queues of waiting EntryEvents

EntryEventServiceDelegate

EntryEventServiceDelegate is a Utility class takes care of handing off between the EntryListener and the EntryEventService. You can configure this class to be the EntryListener on your maps.

Spring based example

There is an example that is started by running HazelcastBookCountOnWordsExample

This example bootstraps the Hazelcast Cluster Member by Spring config found at application-contaxt.xml, it then loads 3 public domain books [AdventuresOfHuckleberryFinn.txt,Metamorphosis.txt,Ulysses.txt] into an IMap. The IMap is keyed by title and the value is the text of the book. There is an EntryListener attached to the map and when each book is put into the map it invokes a WordCountEntryEventProcessor via a ThreadPoolEntryEventService

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.