Class AbstractRedisTool<O,I>
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.gui.visualization.object.tools.AbstractTool
-
- adams.gui.visualization.object.tools.AbstractToolWithParameterPanel
-
- adams.gui.visualization.object.tools.AbstractRedisTool<O,I>
-
- Type Parameters:
O
- the outgoing data (String or byte[])I
- the incoming data (String or byte[])
- All Implemented Interfaces:
adams.core.CleanUpHandler
,adams.core.GlobalInfoSupporter
,adams.core.logging.LoggingLevelHandler
,adams.core.logging.LoggingSupporter
,adams.core.SizeOfHandler
,adams.gui.visualization.object.tools.CustomizableTool
,adams.gui.visualization.object.tools.Tool
,Serializable
public abstract class AbstractRedisTool<O,I> extends adams.gui.visualization.object.tools.AbstractToolWithParameterPanel
Ancestor for tools that exchange data via Redis.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected io.lettuce.core.RedisClient
m_Client
the client object.protected io.lettuce.core.api.StatefulRedisConnection
m_Connection
the connection object.protected io.lettuce.core.pubsub.StatefulRedisPubSubConnection
m_PubSubConnection
the pub/sub connection object.protected io.lettuce.core.pubsub.RedisPubSubListener
m_PubSubListener
the pub/sub listener.protected I
m_ReceivedData
the data received via Redis.protected int
m_RedisDB
the redis database.protected String
m_RedisHost
the redis host.protected int
m_RedisPort
the redis port.protected String
m_RedisReceive
the redis receive channel.protected String
m_RedisSend
the redis send channel.protected int
m_RedisTimeout
the timeout in milli-seconds.protected adams.gui.core.BaseObjectTextField<adams.core.base.BaseHostname>
m_TextRedisHost
the redis host/port.protected adams.gui.core.BaseTextField
m_TextRedisReceive
the redis channel for receiving.protected adams.gui.core.BaseTextField
m_TextRedisSend
the redis channel for sending.protected adams.gui.core.NumberTextField
m_TextRedisTimeout
the redis timeout.-
Fields inherited from class adams.gui.visualization.object.tools.AbstractToolWithParameterPanel
m_ButtonApply
-
-
Constructor Summary
Constructors Constructor Description AbstractRedisTool()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addOptions(adams.gui.core.ParameterPanel paramPanel)
Fills the parameter panel with the options.protected abstract O
assembleSendData(adams.core.MessageCollection errors)
Method that assembles the data to send.protected String
checkBeforeApply()
Checks the parameters before applying them.void
cleanUp()
Cleans up data structures, frees up memory.protected void
doApply()
Applies the settings.protected void
finishedRequest()
Finishes up the request.protected int
getDefaultTimeout()
Returns the default timeout in msec.protected abstract String
getReceiveChannel()
The channel to receive the data on.protected abstract RedisDataType
getReceiveType()
Returns the type of data to receive.protected abstract String
getSendChannel()
The channel to send the data on.protected abstract RedisDataType
getSendType()
Returns the type of data to send.protected io.lettuce.core.pubsub.RedisPubSubListener<byte[],byte[]>
newBytesListener()
Returns a new pub/sub listener for byte arrays.protected io.lettuce.core.pubsub.RedisPubSubListener<String,String>
newStringListener()
Returns a new pub/sub listener for strings.protected abstract void
parseReceivedData(I data, adams.core.MessageCollection errors)
Parses the received data and updates the GUI.protected void
retrieveParameters()
Retrieves the parameters from the GUI.void
sendData()
Communicates with DEXTR and updates the canvas.void
update()
Hook method for when new annotations have been set.-
Methods inherited from class adams.gui.visualization.object.tools.AbstractToolWithParameterPanel
applyOptions, createOptionPanel
-
Methods inherited from class adams.gui.visualization.object.tools.AbstractTool
activate, apply, createApplyButton, createCursor, createKeyListener, createMouseListener, createMouseMotionListener, deactivate, getCanvas, getCursor, getImage, getKeyListener, getMouseListener, getMouseMotionListener, getOptionPanel, getZoom, hasImage, initialize, isModified, setApplyButtonState, setCanvas
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Field Detail
-
m_TextRedisHost
protected adams.gui.core.BaseObjectTextField<adams.core.base.BaseHostname> m_TextRedisHost
the redis host/port.
-
m_TextRedisSend
protected adams.gui.core.BaseTextField m_TextRedisSend
the redis channel for sending.
-
m_TextRedisReceive
protected adams.gui.core.BaseTextField m_TextRedisReceive
the redis channel for receiving.
-
m_TextRedisTimeout
protected adams.gui.core.NumberTextField m_TextRedisTimeout
the redis timeout.
-
m_RedisHost
protected String m_RedisHost
the redis host.
-
m_RedisPort
protected int m_RedisPort
the redis port.
-
m_RedisDB
protected int m_RedisDB
the redis database.
-
m_RedisSend
protected String m_RedisSend
the redis send channel.
-
m_RedisReceive
protected String m_RedisReceive
the redis receive channel.
-
m_RedisTimeout
protected int m_RedisTimeout
the timeout in milli-seconds.
-
m_ReceivedData
protected I m_ReceivedData
the data received via Redis.
-
m_Client
protected transient io.lettuce.core.RedisClient m_Client
the client object.
-
m_PubSubConnection
protected transient io.lettuce.core.pubsub.StatefulRedisPubSubConnection m_PubSubConnection
the pub/sub connection object.
-
m_Connection
protected transient io.lettuce.core.api.StatefulRedisConnection m_Connection
the connection object.
-
m_PubSubListener
protected transient io.lettuce.core.pubsub.RedisPubSubListener m_PubSubListener
the pub/sub listener.
-
-
Method Detail
-
checkBeforeApply
protected String checkBeforeApply()
Checks the parameters before applying them.- Overrides:
checkBeforeApply
in classadams.gui.visualization.object.tools.AbstractTool
- Returns:
- null if checks passed, otherwise error message (gets displayed in GUI)
-
retrieveParameters
protected void retrieveParameters()
Retrieves the parameters from the GUI.
-
doApply
protected void doApply()
Applies the settings.- Specified by:
doApply
in classadams.gui.visualization.object.tools.AbstractTool
-
getSendChannel
protected abstract String getSendChannel()
The channel to send the data on.- Returns:
- the redis channel
-
getReceiveChannel
protected abstract String getReceiveChannel()
The channel to receive the data on.- Returns:
- the redis channel
-
getDefaultTimeout
protected int getDefaultTimeout()
Returns the default timeout in msec.- Returns:
- the timeout
-
addOptions
protected void addOptions(adams.gui.core.ParameterPanel paramPanel)
Fills the parameter panel with the options.- Specified by:
addOptions
in classadams.gui.visualization.object.tools.AbstractToolWithParameterPanel
- Parameters:
paramPanel
- for adding the options to
-
getSendType
protected abstract RedisDataType getSendType()
Returns the type of data to send.- Returns:
- the type of data
-
getReceiveType
protected abstract RedisDataType getReceiveType()
Returns the type of data to receive.- Returns:
- the type of data
-
newStringListener
protected io.lettuce.core.pubsub.RedisPubSubListener<String,String> newStringListener()
Returns a new pub/sub listener for strings.- Returns:
- the listener
-
newBytesListener
protected io.lettuce.core.pubsub.RedisPubSubListener<byte[],byte[]> newBytesListener()
Returns a new pub/sub listener for byte arrays.- Returns:
- the listener
-
assembleSendData
protected abstract O assembleSendData(adams.core.MessageCollection errors)
Method that assembles the data to send.- Parameters:
errors
- for collecting errors- Returns:
- the data to send (String or byte[])
-
parseReceivedData
protected abstract void parseReceivedData(I data, adams.core.MessageCollection errors)
Parses the received data and updates the GUI.- Parameters:
data
- the data to parse (String or byte[])errors
- for collecting errors
-
finishedRequest
protected void finishedRequest()
Finishes up the request.
-
sendData
public void sendData()
Communicates with DEXTR and updates the canvas.
-
update
public void update()
Hook method for when new annotations have been set.- Specified by:
update
in interfaceadams.gui.visualization.object.tools.Tool
- Overrides:
update
in classadams.gui.visualization.object.tools.AbstractTool
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUp
in interfaceadams.core.CleanUpHandler
- Overrides:
cleanUp
in classadams.gui.visualization.object.tools.AbstractTool
-
-