public boolean removeAndGetPartition(String partitionKey, long inUseWaitPeriodMs,
            boolean isWaitTimeoutRollBack, ProcessResult result,
            StringBuilder sBuffer) {
        boolean lastPackConsumed = false;
        List<String> partitionKeys = new ArrayList<>();
        partitionKeys.add(partitionKey);
        pauseProcess();
        try {
            waitPartitions(partitionKeys, inUseWaitPeriodMs);
            PartitionExt partitionExt =
                    rmvPartitionFromMap(partitionKey);
            if (partitionExt == null) {
                result.setSuccResult(null);
                return result.isSuccess();
            }
            lastPackConsumed = partitionExt.isLastPackConsumed();
            if (!cancelTimeTask(partitionKey)
                    && !indexPartition.remove(partitionKey)) {
                logger.info(sBuffer.append("[Process Interrupt] Partition : ")
                        .append(partitionExt.toString())
                        .append(", data in processing, canceled").toString());
                sBuffer.delete(0, sBuffer.length());
                if (lastPackConsumed) {
                    if (isWaitTimeoutRollBack) {
                        lastPackConsumed = false;
                    }
                }
            }
            ConcurrentLinkedQueue<Partition> oldPartitionList =
                    topicPartitionConMap.get(partitionExt.getTopic());
            if (oldPartitionList != null) {
                oldPartitionList.remove(partitionExt);
                if (oldPartitionList.isEmpty()) {
                    topicPartitionConMap.remove(partitionExt.getTopic());
                }
            }
            ConcurrentLinkedQueue<Partition> regMapPartitionList =
                    brokerPartitionConMap.get(partitionExt.getBroker());
            if (regMapPartitionList != null) {
                regMapPartitionList.remove(partitionExt);
                if (regMapPartitionList.isEmpty()) {
                    brokerPartitionConMap.remove(partitionExt.getBroker());
                }
            }
            partitionOffsetMap.remove(partitionKey);
            partitionUsedMap.remove(partitionKey);
            partitionExt.setLastPackConsumed(lastPackConsumed);
            result.setSuccResult(partitionExt);
            return result.isSuccess();
        } finally {
            resumeProcess();
        }
    }
Remove and get required partitions
@param partitionKey      the partition key
@param inUseWaitPeriodMs  the wait period in ms
@param isWaitTimeoutRollBack  whether wait timout
@param result  the process result
@param sBuffer  the string buffer

@return removed or not
inlong-tubemq/tubemq-client/src/main/java/org/apache/inlong/tubemq/client/consumer/RmtDataCache.java