@Override
    public void close(boolean removeParent) {
        if (this.released.compareAndSet(false, true)) {
            if (init.decrementAndGet() == 0) {
                timer.stop();
            }
        }
        if (this.closed.compareAndSet(false, true)) {
            String clientStr;
            if (this.channel != null) {
                clientStr = channel.toString();
            } else {
                clientStr = this.addressInfo.getHostPortStr();
            }
            if (removeParent) {
                this.clientFactory.removeClient(this.getServerAddressInfo());
            }
            if (!requests.isEmpty()) {
                ClientClosedException exception =
                        new ClientClosedException("Client has bean closed.");
                for (Integer serial : requests.keySet()) {
                    if (serial != null) {
                        Callback<ResponseWrapper> callback = requests.remove(serial);
                        if (callback != null) {
                            callback.handleError(exception);
                        }
                    }
                }
            }
            if (this.channel != null) {
                this.channel.close();
                this.channel = null;
            }
            logger.info(new StringBuilder(256).append("Client(")
                    .append(clientStr).append(") closed").toString());
        }
    }
stop timer
remove clientFactory cache
handler unfinished callbacks
and close the channel

@param removeParent    whether remove the object from client factory
inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corerpc/netty/NettyClient.java