net.esper.adapter
Class AbstractCoordinatedAdapter

java.lang.Object
  extended by net.esper.adapter.AbstractCoordinatedAdapter
All Implemented Interfaces:
Adapter, CoordinatedAdapter, InputAdapter
Direct Known Subclasses:
AdapterCoordinatorImpl, CSVInputAdapter

public abstract class AbstractCoordinatedAdapter
extends Object
implements CoordinatedAdapter

A skeleton implementation for coordinated adapter reading, for adapters that can do timestamp-coordinated input.


Field Summary
protected  SortedSet<SendableEvent> eventsToSend
          Sorted events to be sent.
protected  net.esper.schedule.ScheduleSlot scheduleSlot
          Slot for scheduling.
protected  AdapterStateManager stateManager
          Statement management.
 
Fields inherited from interface net.esper.adapter.InputAdapter
ESPERIO_MAP_EVENT_TYPE
 
Constructor Summary
AbstractCoordinatedAdapter(net.esper.client.EPServiceProvider epService, boolean usingEngineThread)
          Ctor.
 
Method Summary
protected abstract  void close()
          Perform any actions specific to this Adapter that should be completed before the Adapter is stopped.
 void destroy()
          Destroy the Adapter, stopping the sending of all events and releasing all the resources, and disallowing any further state changes on the Adapter.
 void disallowStateTransitions()
          Disallow subsequent state changes and throw an IllegalStateTransitionException if they are attempted.
 AdapterState getState()
          Get the state of this Adapter.
 void pause()
          Pause the sending of events after a Adapter has been started.
protected abstract  void replaceFirstEventToSend()
          Remove the first member of eventsToSend and insert another event chosen in some fashion specific to this Adapter.
protected abstract  void reset()
          Reset all the changeable state of this Adapter, as if it were just created.
 void resume()
          Resume sending events after the Adapter has been paused.
 void setEPService(net.esper.client.EPServiceProvider epService)
          Set the epService
 void setScheduleSlot(net.esper.schedule.ScheduleSlot scheduleSlot)
          Set the scheduleSlot for this Adapter.
 void setUsingEngineThread(boolean usingEngineThread)
          Set the usingEngineThread value
 void start()
          Start the sending of events into the runtime egine.
 void stop()
          Stop sending events and return the Adapter to the OPENED state, ready to be started once again.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.esper.adapter.CoordinatedAdapter
read
 

Field Detail

stateManager

protected final AdapterStateManager stateManager
Statement management.


eventsToSend

protected final SortedSet<SendableEvent> eventsToSend
Sorted events to be sent.


scheduleSlot

protected net.esper.schedule.ScheduleSlot scheduleSlot
Slot for scheduling.

Constructor Detail

AbstractCoordinatedAdapter

public AbstractCoordinatedAdapter(net.esper.client.EPServiceProvider epService,
                                  boolean usingEngineThread)
Ctor.

Parameters:
epService - - the EPServiceProvider for the engine runtime and services
usingEngineThread - - true if the Adapter should set time by the scheduling service in the engine, false if it should set time externally through the calling thread
Method Detail

getState

public AdapterState getState()
Description copied from interface: Adapter
Get the state of this Adapter.

Specified by:
getState in interface Adapter
Returns:
state

start

public void start()
           throws net.esper.client.EPException
Description copied from interface: Adapter
Start the sending of events into the runtime egine.

Specified by:
start in interface Adapter
Throws:
net.esper.client.EPException - in case of errors processing the events

pause

public void pause()
           throws net.esper.client.EPException
Description copied from interface: Adapter
Pause the sending of events after a Adapter has been started.

Specified by:
pause in interface Adapter
Throws:
net.esper.client.EPException - if this Adapter has already been stopped

resume

public void resume()
            throws net.esper.client.EPException
Description copied from interface: Adapter
Resume sending events after the Adapter has been paused.

Specified by:
resume in interface Adapter
Throws:
net.esper.client.EPException - in case of errors processing the events

destroy

public void destroy()
             throws net.esper.client.EPException
Description copied from interface: Adapter
Destroy the Adapter, stopping the sending of all events and releasing all the resources, and disallowing any further state changes on the Adapter.

Specified by:
destroy in interface Adapter
Throws:
net.esper.client.EPException - to indicate errors during destroy

stop

public void stop()
          throws net.esper.client.EPException
Description copied from interface: Adapter
Stop sending events and return the Adapter to the OPENED state, ready to be started once again.

Specified by:
stop in interface Adapter
Throws:
net.esper.client.EPException - in case of errors releasing resources

disallowStateTransitions

public void disallowStateTransitions()
Description copied from interface: CoordinatedAdapter
Disallow subsequent state changes and throw an IllegalStateTransitionException if they are attempted.

Specified by:
disallowStateTransitions in interface CoordinatedAdapter

setUsingEngineThread

public void setUsingEngineThread(boolean usingEngineThread)
Description copied from interface: CoordinatedAdapter
Set the usingEngineThread value

Specified by:
setUsingEngineThread in interface CoordinatedAdapter
Parameters:
usingEngineThread - - the value to set

setScheduleSlot

public void setScheduleSlot(net.esper.schedule.ScheduleSlot scheduleSlot)
Description copied from interface: CoordinatedAdapter
Set the scheduleSlot for this Adapter.

Specified by:
setScheduleSlot in interface CoordinatedAdapter
Parameters:
scheduleSlot - - the scheduleSlot to set

setEPService

public void setEPService(net.esper.client.EPServiceProvider epService)
Description copied from interface: CoordinatedAdapter
Set the epService

Specified by:
setEPService in interface CoordinatedAdapter
Parameters:
epService - - the value to set

close

protected abstract void close()
Perform any actions specific to this Adapter that should be completed before the Adapter is stopped.


replaceFirstEventToSend

protected abstract void replaceFirstEventToSend()
Remove the first member of eventsToSend and insert another event chosen in some fashion specific to this Adapter.


reset

protected abstract void reset()
Reset all the changeable state of this Adapter, as if it were just created.