class ClusterNodeEndpoint extends DefaultEndpoint {

    private static final InternalLogger logger = InternalLoggerFactory.getInstance(ClusterNodeEndpoint.class);

    private final RedisChannelWriter clusterChannelWriter;

    /**
     * Initialize a new instance that handles commands from the supplied queue.
     *
     * @param clientOptions client options for this connection.
     * @param clientResources client resources for this connection.
     * @param clusterChannelWriter top-most channel writer.
     */
    public ClusterNodeEndpoint(ClientOptions clientOptions, ClientResources clientResources,
            RedisChannelWriter clusterChannelWriter) {

        super(clientOptions, clientResources);

        this.clusterChannelWriter = clusterChannelWriter;
    }

    /**
     * Move queued and buffered commands from the inactive connection to the upstream command writer. This is done only if the
     * current connection is disconnected and auto-reconnect is enabled (command-retries). If the connection would be open, we
     * could get into a race that the commands we're moving are right now in processing. Alive connections can handle redirects
     * and retries on their own.
     */
    @Override
    public CompletableFuture<Void> closeAsync() {

        logger.debug("{} closeAsync()", logPrefix());

        if (clusterChannelWriter != null) {
            retriggerCommands(doExclusive(this::drainCommands));
        }

        return super.closeAsync();
    }

    protected void retriggerCommands(Collection<RedisCommand<?, ?, ?>> commands) {<FILL_FUNCTION_BODY>}

}


        for (RedisCommand<?, ?, ?> queuedCommand : commands) {
            if (queuedCommand == null || queuedCommand.isCancelled()) {
                continue;
            }

            try {
                clusterChannelWriter.write(queuedCommand);
            } catch (RedisException e) {
                queuedCommand.completeExceptionally(e);
            }
        }
    
<methods>public void <init>(io.lettuce.core.ClientOptions, io.lettuce.core.resource.ClientResources) ,public void addListener(io.lettuce.core.api.push.PushListener) ,public void close() ,public CompletableFuture<java.lang.Void> closeAsync() ,public void disconnect() ,public void flushCommands() ,public io.lettuce.core.resource.ClientResources getClientResources() ,public java.lang.String getId() ,public List<io.lettuce.core.api.push.PushListener> getPushListeners() ,public void initialState() ,public boolean isClosed() ,public void notifyChannelActive(Channel) ,public void notifyChannelInactive(Channel) ,public void notifyDrainQueuedCommands(io.lettuce.core.protocol.HasQueuedCommands) ,public void notifyException(java.lang.Throwable) ,public void registerConnectionWatchdog(io.lettuce.core.protocol.ConnectionWatchdog) ,public void removeListener(io.lettuce.core.api.push.PushListener) ,public void reset() ,public void setAutoFlushCommands(boolean) ,public void setConnectionFacade(io.lettuce.core.protocol.ConnectionFacade) ,public RedisCommand<K,V,T> write(RedisCommand<K,V,T>) ,public Collection<RedisCommand<K,V,?>> write(Collection<? extends RedisCommand<K,V,?>>) <variables>private static final java.util.concurrent.atomic.AtomicLong ENDPOINT_COUNTER,private static final AtomicIntegerFieldUpdater<io.lettuce.core.protocol.DefaultEndpoint> QUEUE_SIZE,private static final AtomicIntegerFieldUpdater<io.lettuce.core.protocol.DefaultEndpoint> STATUS,private static final int ST_CLOSED,private static final int ST_OPEN,private boolean autoFlushCommands,private final non-sealed boolean boundedQueues,private final non-sealed java.lang.String cachedEndpointId,protected volatile Channel channel,private final non-sealed io.lettuce.core.ClientOptions clientOptions,private final non-sealed io.lettuce.core.resource.ClientResources clientResources,private final CompletableFuture<java.lang.Void> closeFuture,private final non-sealed Queue<RedisCommand<?,?,?>> commandBuffer,private volatile java.lang.Throwable connectionError,private io.lettuce.core.protocol.ConnectionFacade connectionFacade,private io.lettuce.core.protocol.ConnectionWatchdog connectionWatchdog,private final boolean debugEnabled,private final non-sealed Queue<RedisCommand<?,?,?>> disconnectedBuffer,private final long endpointId,private boolean inActivation,private java.lang.String logPrefix,private static final InternalLogger logger,private final List<io.lettuce.core.api.push.PushListener> pushListeners,private volatile int queueSize,private final non-sealed boolean rejectCommandsWhileDisconnected,private final non-sealed io.lettuce.core.protocol.DefaultEndpoint.Reliability reliability,private final io.lettuce.core.protocol.SharedLock sharedLock,private volatile int status