public override void Suspend()
        {
            log.Debug($"{logPrefix}Suspending");

            try
            {
                Commit(false);
            }
            finally
            {
                partitionGrouper.Clear();

                if (eosEnabled)
                {
                    if (transactionInFlight)
                    {
                        producer.AbortTransaction(configuration.TransactionTimeout);
                    }

                    collector.Close();
                    producer = null;
                }
            }
        }
        public override void Suspend()
        {
            log.LogDebug($"{logPrefix}Suspending");

            if (state == TaskState.CREATED || state == TaskState.RESTORING)
            {
                log.LogInformation($"{logPrefix}Suspended {(state == TaskState.CREATED ? "created" : "restoring")}");

                // TODO : remove when stream task refactoring is finished
                if (eosEnabled)
                {
                    if (transactionInFlight)
                    {
                        producer.AbortTransaction(configuration.TransactionTimeout);
                    }

                    collector.Close();
                    producer = null;
                }

                FlushState();
                CloseStateManager();

                TransitTo(TaskState.SUSPENDED);
            }
            else if (state == TaskState.RUNNING)
            {
                try
                {
                    Commit(false);
                }
                finally
                {
                    partitionGrouper.Clear();

                    if (eosEnabled)
                    {
                        if (transactionInFlight)
                        {
                            producer.AbortTransaction(configuration.TransactionTimeout);
                        }

                        collector.Close();
                        producer = null;
                    }

                    FlushState();
                    CloseStateManager();
                }

                log.LogInformation($"{logPrefix}Suspended running");
                TransitTo(TaskState.SUSPENDED);
            }
            else if (state == TaskState.SUSPENDED)
            {
                log.LogInformation($"{logPrefix}Skip suspended since state is {state}");
                return;
            }
            else if (state == TaskState.CLOSED)
            {
                throw new IllegalStateException($"Illegal state {state} while suspending active task {Id}");
            }
            else
            {
                throw new IllegalStateException($"Unknow state {state} while suspending active task {Id}");
            }
        }