You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by tillrohrmann <gi...@git.apache.org> on 2015/12/01 11:49:21 UTC

[GitHub] flink pull request: Out-of-core state backend for JDBC databases

Github user tillrohrmann commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1305#discussion_r46264109
  
    --- Diff: flink-contrib/flink-streaming-contrib/src/main/java/org/apache/flink/contrib/streaming/state/DbStateBackend.java ---
    @@ -0,0 +1,248 @@
    +/*
    + * 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.flink.contrib.streaming.state;
    +
    +import java.io.IOException;
    +import java.io.Serializable;
    +import java.sql.Connection;
    +import java.sql.PreparedStatement;
    +import java.sql.SQLException;
    +import java.util.Random;
    +import java.util.concurrent.Callable;
    +
    +import org.apache.flink.api.common.typeutils.TypeSerializer;
    +import org.apache.flink.runtime.execution.Environment;
    +import org.apache.flink.runtime.state.StateBackend;
    +import org.apache.flink.runtime.state.StateHandle;
    +import org.apache.flink.util.InstantiationUtil;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import static org.apache.flink.contrib.streaming.state.SQLRetrier.retry;
    +
    +/**
    + * {@link StateBackend} for storing checkpoints in JDBC supporting databases.
    + * Key-Value state is stored out-of-core and is lazily fetched using the
    + * {@link LazyDbKvState} implementation. A different backend can also be
    + * provided in the constructor to store the non-partitioned states. A common use
    + * case would be to store the key-value states in the database and store larger
    + * non-partitioned states on a distributed file system.
    + * <p>
    + * This backend implementation also allows the sharding of the checkpointed
    + * states among multiple database instances, which can be enabled by passing
    + * multiple database urls to the {@link DbBackendConfig} instance.
    + * <p>
    + * By default there are multiple tables created in the given databases: 1 table
    + * for non-partitioned checkpoints and 1 table for each key-value state in the
    + * streaming program.
    + * <p>
    + * To control table creation, insert/lookup operations and to provide
    + * compatibility for different SQL implementations, a custom
    + * {@link MySqlAdapter} can be supplied in the {@link DbBackendConfig}.
    + *
    + */
    +public class DbStateBackend extends StateBackend<DbStateBackend> {
    +
    +	private static final long serialVersionUID = 1L;
    +	private static final Logger LOG = LoggerFactory.getLogger(DbStateBackend.class);
    +
    +	private Random rnd;
    +
    +	// ------------------------------------------------------
    +
    +	private Environment env;
    --- End diff --
    
    `env` is not serializable


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---