Chapter 1. Adapter Overview

Input and output adapters to Esper provide the means of accepting events from various sources, and for making available events to destinations.

The following input adapters exist. There are currently no output adapters available.

Table 1.1. Input and Output Adapters

AdapterDescription
CSV Input Adapter

The CSV input adapter can read one or more CSV-formatted input sources, transform the textual values into events, and play the events into the engine. The adapter also makes it possible to run complete simulations of events arriving in time-order from different input streams.

1.1. Adapter Library Classes

1.1.1. Using AdapterInputSource

The net.esper.adapter.AdapterInputSource encapsulates information about an input source. Input adapters use the AdapterInputSource to determine how to read input. The class provides constructors for use with different input sources:

  • java.io.Reader to read character streams

  • java.io.InputStream to read byte streams

  • java.net.URL

  • Classpath resource by name

  • java.io.File

Adapters resolve Classpath resources in the following order:

  1. Current thread classloader via Thread.currentThread().getContextClassLoader().getResourceAsStream

  2. If the resource is not found: AdapterInputSource.class.getResourceAsStream

  3. If the resource is not found: AdapterInputSource.class.getClassLoader().getResourceAsStream

1.1.2. The InputAdapter Interface

The InputAdapter interface allows client applications to control the state of an input adapter. It provides state transition methods that each input adapter implements.

An input adapter is always in one of the following states:

  • Opened - The begin state; The adapter is not generating events in this state

  • Started - When the adapter is active and generating events

  • Paused - When operation of the adapter is suspended

  • Destroyed

The state transition table below outlines input adapter states and, for each state, the valid state transitions:

Table 1.2. Adapter State Transitions

Start StateMethodNext State
Openedstart()Started
Openeddestroy()Destroyed
Startedstop()Opened
Startedpause()Paused
Starteddestroy()Destroyed
Pausedresume()Started
Pausedstop()Opened
Pauseddestroy()Destroyed