kafka ReadOnlyTask 源码

  • 2022-10-20
  • 浏览 (331)

kafka ReadOnlyTask 代码

文件路径:/streams/src/main/java/org/apache/kafka/streams/processor/internals/ReadOnlyTask.java

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.kafka.streams.processor.internals;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.OffsetAndMetadata;
import org.apache.kafka.common.TopicPartition;
import org.apache.kafka.streams.processor.StateStore;
import org.apache.kafka.streams.processor.TaskId;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Consumer;

public class ReadOnlyTask implements Task {

    private final Task task;

    public ReadOnlyTask(final Task task) {
        this.task = task;
    }

    @Override
    public TaskId id() {
        return task.id();
    }

    @Override
    public boolean isActive() {
        return task.isActive();
    }

    @Override
    public Set<TopicPartition> inputPartitions() {
        return task.inputPartitions();
    }

    @Override
    public Set<TopicPartition> changelogPartitions() {
        return task.changelogPartitions();
    }

    @Override
    public State state() {
        return task.state();
    }

    @Override
    public boolean commitRequested() {
        return task.commitRequested();
    }

    @Override
    public boolean needsInitializationOrRestoration() {
        return task.needsInitializationOrRestoration();
    }

    @Override
    public void initializeIfNeeded() {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public void addPartitionsForOffsetReset(final Set<TopicPartition> partitionsForOffsetReset) {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public void completeRestoration(final Consumer<Set<TopicPartition>> offsetResetter) {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public void suspend() {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public void resume() {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public void closeDirty() {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public void closeClean() {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public void updateInputPartitions(final Set<TopicPartition> topicPartitions,
                                      final Map<String, List<String>> allTopologyNodesToSourceTopics) {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public void maybeCheckpoint(final boolean enforceCheckpoint) {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public void markChangelogAsCorrupted(final Collection<TopicPartition> partitions) {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public void revive() {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public void prepareRecycle() {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public void addRecords(final TopicPartition partition, final Iterable<ConsumerRecord<byte[], byte[]>> records) {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public boolean process(final long wallClockTime) {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public void recordProcessBatchTime(final long processBatchTime) {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public void recordProcessTimeRatioAndBufferSize(final long allTaskProcessMs, final long now) {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public boolean maybePunctuateStreamTime() {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public boolean maybePunctuateSystemTime() {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public Map<TopicPartition, OffsetAndMetadata> prepareCommit() {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public void postCommit(final boolean enforceCheckpoint) {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public Map<TopicPartition, Long> purgeableOffsets() {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public void maybeInitTaskTimeoutOrThrow(final long currentWallClockMs, final Exception cause) {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public void clearTaskTimeout() {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public boolean commitNeeded() {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public StateStore getStore(final String name) {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public Map<TopicPartition, Long> changelogOffsets() {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public Map<TopicPartition, Long> committedOffsets() {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public Map<TopicPartition, Long> highWaterMark() {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public Optional<Long> timeCurrentIdlingStarted() {
        throw new UnsupportedOperationException("This task is read-only");
    }

    @Override
    public ProcessorStateManager stateManager() {
        throw new UnsupportedOperationException("This task is read-only");
    }
}

相关信息

kafka 源码目录

相关文章

kafka AbstractProcessorContext 源码

kafka AbstractReadOnlyDecorator 源码

kafka AbstractReadWriteDecorator 源码

kafka AbstractTask 源码

kafka ActiveTaskCreator 源码

kafka ChangelogReader 源码

kafka ChangelogRecordDeserializationHelper 源码

kafka ChangelogRegister 源码

kafka ChangelogTopics 源码

kafka ClientUtils 源码

0  赞