org.apache.kafka.streams.processor.StateStoreContext Maven / Gradle / Ivy
/*
* 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;
import org.apache.kafka.common.serialization.Serde;
import org.apache.kafka.streams.StreamsMetrics;
import org.apache.kafka.streams.errors.StreamsException;
import java.io.File;
import java.util.Map;
/**
* State store context interface.
*/
public interface StateStoreContext {
/**
* Returns the application id.
*
* @return the application id
*/
String applicationId();
/**
* Returns the task id.
*
* @return the task id
*/
TaskId taskId();
/**
* Returns the default key serde.
*
* @return the key serializer
*/
Serde keySerde();
/**
* Returns the default value serde.
*
* @return the value serializer
*/
Serde valueSerde();
/**
* Returns the state directory for the partition.
*
* @return the state directory
*/
File stateDir();
/**
* Returns Metrics instance.
*
* @return StreamsMetrics
*/
StreamsMetrics metrics();
/**
* Registers and possibly restores the specified storage engine.
*
* @param store the storage engine
* @param stateRestoreCallback the restoration callback logic for log-backed state stores upon restart
*
* @throws IllegalStateException If store gets registered after initialized is already finished
* @throws StreamsException if the store's change log does not contain the partition
*/
void register(final StateStore store,
final StateRestoreCallback stateRestoreCallback);
/**
* Returns all the application config properties as key/value pairs.
*
* The config properties are defined in the {@link org.apache.kafka.streams.StreamsConfig}
* object and associated to the StateStoreContext.
*
*
The type of the values is dependent on the {@link org.apache.kafka.common.config.ConfigDef.Type type} of the property
* (e.g. the value of {@link org.apache.kafka.streams.StreamsConfig#DEFAULT_KEY_SERDE_CLASS_CONFIG DEFAULT_KEY_SERDE_CLASS_CONFIG}
* will be of type {@link Class}, even if it was specified as a String to
* {@link org.apache.kafka.streams.StreamsConfig#StreamsConfig(Map) StreamsConfig(Map)}).
*
* @return all the key/values from the StreamsConfig properties
*/
Map appConfigs();
/**
* Returns all the application config properties with the given key prefix, as key/value pairs
* stripping the prefix.
*
* The config properties are defined in the {@link org.apache.kafka.streams.StreamsConfig}
* object and associated to the StateStoreContext.
*
* @param prefix the properties prefix
* @return the key/values matching the given prefix from the StreamsConfig properties.
*/
Map appConfigsWithPrefix(final String prefix);
}