public class DefaultEndpoint extends Object implements RedisChannelWriter, Endpoint
Endpoint implementation.| Constructor and Description |
|---|
DefaultEndpoint(ClientOptions clientOptions,
ClientResources clientResources)
Create a new
DefaultEndpoint. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the connection.
|
CompletableFuture<Void> |
closeAsync()
Asynchronously close the
RedisChannelWriter. |
protected <T> T |
doExclusive(Supplier<T> supplier)
Execute a
Supplier callback guarded by an exclusive lock. |
protected List<RedisCommand<?,?,?>> |
drainCommands() |
void |
flushCommands()
Flush pending commands.
|
ClientResources |
getClientResources() |
void |
initialState()
Reset the command-handler to the initial not-connected state.
|
boolean |
isClosed() |
protected String |
logPrefix() |
void |
notifyChannelActive(Channel channel)
Notify about channel activation.
|
void |
notifyChannelInactive(Channel channel)
Notify about channel deactivation.
|
void |
notifyDrainQueuedCommands(io.lettuce.core.protocol.HasQueuedCommands queuedCommands)
Signal the endpoint to drain queued commands from the queue holder.
|
void |
notifyException(Throwable t)
Notify about an exception occured in channel/command processing
|
void |
registerConnectionWatchdog(ConnectionWatchdog connectionWatchdog)
Associate a
ConnectionWatchdog with the Endpoint. |
void |
reset()
Reset the writer state.
|
void |
setAutoFlushCommands(boolean autoFlush)
Disable or enable auto-flush behavior.
|
void |
setConnectionFacade(ConnectionFacade connectionFacade)
Set the corresponding connection facade in order to notify it about channel active/inactive state.
|
<K,V> Collection<RedisCommand<K,V,?>> |
write(Collection<? extends RedisCommand<K,V,?>> commands)
Write multiple commands on the channel.
|
<K,V,T> RedisCommand<K,V,T> |
write(RedisCommand<K,V,T> command)
Write a command on the channel.
|
protected <C extends RedisCommand<?,?,T>,T> |
writeToBuffer(C command) |
protected volatile Channel channel
public DefaultEndpoint(ClientOptions clientOptions, ClientResources clientResources)
DefaultEndpoint.clientOptions - client options for this connection, must not be null.clientResources - client resources for this connection, must not be null.public void setConnectionFacade(ConnectionFacade connectionFacade)
RedisChannelWritersetConnectionFacade in interface RedisChannelWriterconnectionFacade - the connection facade (external connection object)public ClientResources getClientResources()
getClientResources in interface RedisChannelWriterClientResources.public void setAutoFlushCommands(boolean autoFlush)
RedisChannelWriterRedisChannelWriter.flushCommands() is
issued. After calling RedisChannelWriter.flushCommands() commands are sent to the transport and executed by Redis.setAutoFlushCommands in interface RedisChannelWriterautoFlush - state of autoFlush.public <K,V,T> RedisCommand<K,V,T> write(RedisCommand<K,V,T> command)
RedisChannelWriterwrite in interface RedisChannelWriterT - result typecommand - the Redis command.public <K,V> Collection<RedisCommand<K,V,?>> write(Collection<? extends RedisCommand<K,V,?>> commands)
RedisChannelWriterwrite in interface RedisChannelWriterK - key typeV - value typecommands - the Redis commands.protected <C extends RedisCommand<?,?,T>,T> void writeToBuffer(C command)
public void notifyChannelActive(Channel channel)
EndpointnotifyChannelActive in interface Endpointchannel - the channelpublic void notifyChannelInactive(Channel channel)
EndpointnotifyChannelInactive in interface Endpointchannel - the channelpublic void notifyException(Throwable t)
EndpointnotifyException in interface Endpointt - the Exceptionpublic void registerConnectionWatchdog(ConnectionWatchdog connectionWatchdog)
EndpointConnectionWatchdog with the Endpoint.registerConnectionWatchdog in interface EndpointconnectionWatchdog - the connection watchdog.public void flushCommands()
RedisChannelWriterflushCommands in interface RedisChannelWriterpublic void close()
close in interface RedisChannelWriterclose in interface Closeableclose in interface AutoCloseablepublic CompletableFuture<Void> closeAsync()
RedisChannelWriterRedisChannelWriter.closeAsync in interface AsyncCloseablecloseAsync in interface RedisChannelWriterpublic void reset()
reset in interface RedisChannelWriterpublic void initialState()
initialState in interface Endpointpublic void notifyDrainQueuedCommands(io.lettuce.core.protocol.HasQueuedCommands queuedCommands)
EndpointnotifyDrainQueuedCommands in interface EndpointqueuedCommands - the queue holder.public boolean isClosed()
protected <T> T doExclusive(Supplier<T> supplier)
Supplier callback guarded by an exclusive lock.T - supplier - protected List<RedisCommand<?,?,?>> drainCommands()
protected String logPrefix()
Copyright © 2019 lettuce.io. All rights reserved.