Class Reactor
- java.lang.Object
-
- java.lang.Thread
-
- org.ovirt.vdsm.jsonrpc.client.reactors.Reactor
-
- All Implemented Interfaces:
java.lang.Runnable
- Direct Known Subclasses:
SSLStompReactor
,StompReactor
public abstract class Reactor extends java.lang.Thread
ProvidesReactor
abstraction which reacts on incoming messages and letReactorClient
process them.
-
-
Constructor Summary
Constructors Constructor Description Reactor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private void
checkActions(java.util.Set<java.nio.channels.SelectionKey> keys)
void
close()
ReactorClient
createClient(java.lang.String hostname, int port)
protected abstract ReactorClient
createClient(Reactor reactor, java.nio.channels.Selector selector, java.lang.String hostname, int port)
protected abstract ReactorClient
createConnectedClient(Reactor reactor, java.nio.channels.Selector selector, java.lang.String hostname, int port, java.nio.channels.SocketChannel channel)
java.util.concurrent.Future<ReactorListener>
createListener(java.lang.String hostname, int port, ReactorListener.EventListener owner)
protected abstract java.lang.String
getReactorName()
private void
handleException(java.lang.Throwable t, ReactorClient client, java.nio.channels.SelectionKey key, java.lang.String message)
private void
processChannels()
Processing channels.void
queueFuture(java.util.concurrent.Future<?> f)
void
run()
Main loop for message processing.private void
select()
void
wakeup()
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
LOG
private static final org.slf4j.Logger LOG
-
TIMEOUT
private static final int TIMEOUT
- See Also:
- Constant Field Values
-
selector
private final java.nio.channels.spi.AbstractSelector selector
-
scheduler
private final ReactorScheduler scheduler
-
isRunning
private boolean isRunning
-
-
Method Detail
-
select
private void select()
-
run
public void run()
Main loop for message processing.- Specified by:
run
in interfacejava.lang.Runnable
- Overrides:
run
in classjava.lang.Thread
-
processChannels
private void processChannels()
Processing channels.
-
checkActions
private void checkActions(java.util.Set<java.nio.channels.SelectionKey> keys)
-
handleException
private void handleException(java.lang.Throwable t, ReactorClient client, java.nio.channels.SelectionKey key, java.lang.String message)
-
queueFuture
public void queueFuture(java.util.concurrent.Future<?> f)
-
wakeup
public void wakeup()
-
createListener
public java.util.concurrent.Future<ReactorListener> createListener(java.lang.String hostname, int port, ReactorListener.EventListener owner) throws ClientConnectionException
- Throws:
ClientConnectionException
-
createClient
public ReactorClient createClient(java.lang.String hostname, int port) throws ClientConnectionException
- Throws:
ClientConnectionException
-
close
public void close() throws java.io.IOException
- Throws:
java.io.IOException
-
createClient
protected abstract ReactorClient createClient(Reactor reactor, java.nio.channels.Selector selector, java.lang.String hostname, int port) throws ClientConnectionException
- Throws:
ClientConnectionException
-
createConnectedClient
protected abstract ReactorClient createConnectedClient(Reactor reactor, java.nio.channels.Selector selector, java.lang.String hostname, int port, java.nio.channels.SocketChannel channel) throws ClientConnectionException
- Throws:
ClientConnectionException
-
getReactorName
protected abstract java.lang.String getReactorName()
-
-