public boolean write(long termId, EncodeObject encodeObject, ProcessResult procResult) {
        if (this.conStatus.get() != CLIENT_STATUS_READY) {
            return procResult.setFailResult(ErrorCode.CONNECTION_UNAVAILABLE);
        }
        this.rw.readLock().lock();
        if (this.conStatus.get() != CLIENT_STATUS_READY) {
            return procResult.setFailResult(ErrorCode.CONNECTION_UNAVAILABLE);
        }
        if (this.channelTermId.get() != termId) {
            return procResult.setFailResult(ErrorCode.CONNECTION_BREAK);
        }
        if (!(this.channel.isOpen()
                && this.channel.isActive() && this.channel.isWritable())) {
            return procResult.setFailResult(ErrorCode.CONNECTION_UNWRITABLE);
        }
        try {
            this.msgSentCnt.incrementAndGet();
            this.channel.writeAndFlush(encodeObject);
            this.msgInflightCnt.incrementAndGet();
            return procResult.setSuccess();
        } catch (Throwable ex) {
            if (conExptCnt.shouldPrint()) {
                logger.warn("NettyClient({}) write {} exception",
                        this.senderId, this.channel.toString(), ex);
            }
            return procResult.setFailResult(ErrorCode.CONNECTION_WRITE_EXCEPTION, ex.getMessage());
        } finally {
            this.rw.readLock().unlock();
        }
    }
TCP Netty client class

Used to manage TCP netty client, including connection, closing, keep-alive, sending status check, etc.
inlong-sdk/dataproxy-sdk/src/main/java/org/apache/inlong/sdk/dataproxy/network/tcp/TcpNettyClient.java