Class MockSelector
java.lang.Object
org.apache.kafka.test.MockSelector
- All Implemented Interfaces:
org.apache.kafka.common.network.Selectable
A fake selector to use for testing
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.kafka.common.network.Selectable
org.apache.kafka.common.network.Selectable.Listener -
Field Summary
Fields inherited from interface org.apache.kafka.common.network.Selectable
NOOP_LISTENER, USE_DEFAULT_BUFFER_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionMockSelector(org.apache.kafka.common.utils.Time time) MockSelector(org.apache.kafka.common.utils.Time time, Predicate<InetSocketAddress> canConnect) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidclear()voidclose()voidList<org.apache.kafka.common.network.NetworkReceive> List<org.apache.kafka.common.network.NetworkSend> voidcompleteReceive(org.apache.kafka.common.network.NetworkReceive receive) voidconnect(String id, InetSocketAddress address, int sendBufferSize, int receiveBufferSize) voiddelayedReceive(DelayedReceive receive) booleanisChannelReady(String id) voidvoidmuteAll()voidpoll(long timeout) voidreset()voidsend(org.apache.kafka.common.network.NetworkSend send) voidvoidSince MockSelector.connect will always succeed and add the connection id to the Set connected, we can only simulate that the connection is still pending by removing the connection id from the Set connected.voidSimulate a server disconnect.voidvoidvoidwakeup()Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.kafka.common.network.Selectable
channelsWithCredential
-
Constructor Details
-
MockSelector
public MockSelector(org.apache.kafka.common.utils.Time time) -
MockSelector
public MockSelector(org.apache.kafka.common.utils.Time time, Predicate<InetSocketAddress> canConnect)
-
-
Method Details
-
connect
public void connect(String id, InetSocketAddress address, int sendBufferSize, int receiveBufferSize) throws IOException - Specified by:
connectin interfaceorg.apache.kafka.common.network.Selectable- Throws:
IOException
-
wakeup
public void wakeup()- Specified by:
wakeupin interfaceorg.apache.kafka.common.network.Selectable
-
close
public void close()- Specified by:
closein interfaceorg.apache.kafka.common.network.Selectable
-
close
- Specified by:
closein interfaceorg.apache.kafka.common.network.Selectable
-
serverConnectionBlocked
Since MockSelector.connect will always succeed and add the connection id to the Set connected, we can only simulate that the connection is still pending by removing the connection id from the Set connected.- Parameters:
id- connection id
-
serverDisconnect
Simulate a server disconnect. This id will be present indisconnected()on the nextpoll(long). -
serverAuthenticationFailed
-
clear
public void clear() -
send
public void send(org.apache.kafka.common.network.NetworkSend send) - Specified by:
sendin interfaceorg.apache.kafka.common.network.Selectable
-
poll
- Specified by:
pollin interfaceorg.apache.kafka.common.network.Selectable- Throws:
IOException
-
completedSends
- Specified by:
completedSendsin interfaceorg.apache.kafka.common.network.Selectable
-
completedSendBuffers
-
completedReceives
- Specified by:
completedReceivesin interfaceorg.apache.kafka.common.network.Selectable
-
completeReceive
public void completeReceive(org.apache.kafka.common.network.NetworkReceive receive) -
delayedReceive
-
disconnected
-
connected
-
mute
- Specified by:
mutein interfaceorg.apache.kafka.common.network.Selectable
-
unmute
- Specified by:
unmutein interfaceorg.apache.kafka.common.network.Selectable
-
muteAll
public void muteAll()- Specified by:
muteAllin interfaceorg.apache.kafka.common.network.Selectable
-
unmuteAll
public void unmuteAll()- Specified by:
unmuteAllin interfaceorg.apache.kafka.common.network.Selectable
-
channelNotReady
-
isChannelReady
- Specified by:
isChannelReadyin interfaceorg.apache.kafka.common.network.Selectable
-
reset
public void reset()
-