0
votes

I'm trying to use flink-streaming state backend, following this guide: https://ci.apache.org/projects/flink/flink-docs-master/apis/streaming/state.html, but I get the error: Cannot Resolve Symbol 'ValueState'.

After looking a bit, I realise that ValueState is not in my dependencies. Instead, only OperatorState is in org.apache.flink.api.common.state (flink-core).

However, if I look on Github, I see ValueState in that package: https://github.com/apache/flink/tree/master/flink-core/src/main/java/org/apache/flink/api/common/state

I'm guessing I either don't have the right version of flink to use the StateBackend the way the guide shows it, or maybe I have the right version but the ValueState has been moved to another maven dependency.

Below is my pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>test</groupId>
<artifactId>flink-streaming</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>flink-streaming</name>
<url>http://maven.apache.org</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <!--<flink.version>0.10.2</flink.version>-->
    <flink.version>0.10.2</flink.version>
    <scala.version>2.11.8</scala.version>
    <scala.dependency.version>2.11</scala.dependency.version>
</properties>


<dependencies>
    <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-library</artifactId>
        <version>${scala.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.flink</groupId>
        <artifactId>flink-scala_${scala.dependency.version}</artifactId>
        <version>${flink.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.flink</groupId>
        <artifactId>flink-clients_${scala.dependency.version}</artifactId>
        <version>${flink.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.flink</groupId>
        <artifactId>flink-streaming-scala_${scala.dependency.version}</artifactId>
        <version>${flink.version}</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.scala-tools</groupId>
            <artifactId>maven-scala-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <jvmArgs>
                    <jvmArg>-Xms64m</jvmArg>
                    <jvmArg>-Xmx1024m</jvmArg>
                </jvmArgs>
            </configuration>
        </plugin>

    </plugins>
</build>

And here is my code:

import org.apache.flink.api.common.functions.RichFlatMapFunction;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.util.Collector;


public class CountWindowAverage extends RichFlatMapFunction<Tuple2<Long,Long>, Tuple2<Long,Long>> {
    private transient ValueState<Tuple2<Long,Long>> sum;

    @Override
    public void flatMap(Tuple2<Long,Long> input, Collector<Tuple2<Long,Long>> out) throws Exception {

    }
}

Thanks a lot in advance for your help!

Laurent.

1

1 Answers

0
votes

You're right Flink version 0.10.x did not yet have ValueState. If you switch to at least version 1.0.0 you should be all right.