Package org.apache.thrift.transport.sasl
Class NonblockingSaslHandler
java.lang.Object
org.apache.thrift.transport.sasl.NonblockingSaslHandler
State machine managing one sasl connection in a nonblocking way.
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionNonblockingSaslHandler
(SelectionKey selectionKey, TNonblockingTransport underlyingTransport, TSaslServerFactory saslServerFactory, TSaslProcessorFactory processorFactory, TProtocolFactory inputProtocolFactory, TProtocolFactory outputProtocolFactory, TServerEventHandler eventHandler) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Release all the resources managed by this state machine (connection, selection and sasl server).Get current phase of the state machine.Get next phase of the state machine.void
When current phase is intrested in read selection, calling this will run the current phase and its following phases if the following ones are interested to read, until there is nothing available in the underlying transport.void
Similiar to handleRead.boolean
void
Run state machine.void
When current phase is finished, it's expected to call this method first before running the state machine again.
-
Constructor Details
-
NonblockingSaslHandler
public NonblockingSaslHandler(SelectionKey selectionKey, TNonblockingTransport underlyingTransport, TSaslServerFactory saslServerFactory, TSaslProcessorFactory processorFactory, TProtocolFactory inputProtocolFactory, TProtocolFactory outputProtocolFactory, TServerEventHandler eventHandler)
-
-
Method Details
-
getCurrentPhase
Get current phase of the state machine.- Returns:
- current phase.
-
getNextPhase
Get next phase of the state machine. It is different from current phase iff current phase is done (and next phase not yet started).- Returns:
- next phase.
-
getUnderlyingTransport
- Returns:
- underlying nonblocking socket
-
getSaslServer
- Returns:
- SaslServer instance
-
isCurrentPhaseDone
public boolean isCurrentPhaseDone()- Returns:
- true if current phase is done.
-
runCurrentPhase
public void runCurrentPhase()Run state machine.- Throws:
IllegalStateException
- if current state is already done.
-
handleRead
public void handleRead()When current phase is intrested in read selection, calling this will run the current phase and its following phases if the following ones are interested to read, until there is nothing available in the underlying transport.- Throws:
IllegalStateException
- if is called in an irrelevant phase.
-
handleWrite
public void handleWrite()Similiar to handleRead. But it is for write ops.- Throws:
IllegalStateException
- if it is called in an irrelevant phase.
-
stepToNextPhase
public void stepToNextPhase()When current phase is finished, it's expected to call this method first before running the state machine again. By calling this, "next phase" is marked as started (and not done), thus is ready to run.- Throws:
IllegalArgumentException
- if current phase is not yet done.
-
close
public void close()Release all the resources managed by this state machine (connection, selection and sasl server). To avoid being blocked, this should be invoked in the network thread that manages the selector.
-