[ 
https://issues.apache.org/jira/browse/FLINK-5823?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16320583#comment-16320583
 ] 

ASF GitHub Bot commented on FLINK-5823:
---------------------------------------

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

    https://github.com/apache/flink/pull/5248#discussion_r160686745
  
    --- Diff: 
flink-runtime/src/main/java/org/apache/flink/runtime/state/StateBackendLoader.java
 ---
    @@ -0,0 +1,265 @@
    +/*
    + * 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.runtime.state;
    +
    +import org.apache.flink.configuration.CheckpointingOptions;
    +import org.apache.flink.configuration.Configuration;
    +import org.apache.flink.configuration.HighAvailabilityOptions;
    +import org.apache.flink.configuration.IllegalConfigurationException;
    +import org.apache.flink.core.fs.Path;
    +import org.apache.flink.runtime.jobmanager.HighAvailabilityMode;
    +import org.apache.flink.runtime.state.filesystem.FsStateBackend;
    +import org.apache.flink.runtime.state.filesystem.FsStateBackendFactory;
    +import org.apache.flink.runtime.state.memory.MemoryStateBackend;
    +import org.apache.flink.runtime.state.memory.MemoryStateBackendFactory;
    +import org.apache.flink.util.DynamicCodeLoadingException;
    +
    +import org.slf4j.Logger;
    +
    +import javax.annotation.Nullable;
    +
    +import java.io.IOException;
    +import java.util.UUID;
    +
    +import static org.apache.flink.util.Preconditions.checkNotNull;
    +
    +/**
    + * This class contains utility methods to load state backends from 
configurations.
    + */
    +public class StateBackendLoader {
    +
    +   // 
------------------------------------------------------------------------
    +   //  Configuration shortcut names
    +   // 
------------------------------------------------------------------------
    +
    +   /** The shortcut configuration name for the MemoryState backend that 
checkpoints to the JobManager */
    +   public static final String MEMORY_STATE_BACKEND_NAME = "jobmanager";
    +
    +   /** The shortcut configuration name for the FileSystem State backend */
    +   public static final String FS_STATE_BACKEND_NAME = "filesystem";
    +
    +   /** The shortcut configuration name for the RocksDB State Backend */
    +   public static final String ROCKSDB_STATE_BACKEND_NAME = "rocksdb";
    +
    +   // 
------------------------------------------------------------------------
    +   //  Loading the state backend from a configuration 
    +   // 
------------------------------------------------------------------------
    +
    +   /**
    +    * Loads the state backend from the configuration, from the parameter 
'state.backend', as defined
    +    * in {@link CheckpointingOptions#STATE_BACKEND}.
    +    *
    +    * <p>The state backends can be specified either via their shortcut 
name, or via the class name
    +    * of a {@link StateBackendFactory}. If a StateBackendFactory class 
name is specified, the factory
    +    * is instantiated (via its zero-argument constructor) and its
    +    * {@link StateBackendFactory#createFromConfig(Configuration)} method 
is called.
    +    *
    +    * <p>Recognized shortcut names are '{@value 
StateBackendLoader#MEMORY_STATE_BACKEND_NAME}',
    +    * '{@value StateBackendLoader#FS_STATE_BACKEND_NAME}', and
    +    * '{@value StateBackendLoader#ROCKSDB_STATE_BACKEND_NAME}'.
    +    *
    +    * @param config The configuration to load the state backend from
    +    * @param classLoader The class loader that should be used to load the 
state backend
    +    * @param logger Optionally, a logger to log actions to (may be null)
    +    *
    +    * @return The instantiated state backend.
    +    *
    +    * @throws DynamicCodeLoadingException
    +    *             Thrown if a state backend factory is configured and the 
factory class was not
    +    *             found or the factory could not be instantiated
    +    * @throws IllegalConfigurationException
    +    *             May be thrown by the StateBackendFactory when creating / 
configuring the state
    +    *             backend in the factory
    +    * @throws IOException
    +    *             May be thrown by the StateBackendFactory when 
instantiating the state backend
    +    */
    +   public static StateBackend loadStateBackendFromConfig(
    +                   Configuration config,
    +                   ClassLoader classLoader,
    +                   @Nullable Logger logger) throws 
IllegalConfigurationException, DynamicCodeLoadingException, IOException {
    +
    +           checkNotNull(config, "config");
    +           checkNotNull(classLoader, "classLoader");
    +
    +           final String backendName = 
config.getString(CheckpointingOptions.STATE_BACKEND);
    +           if (backendName == null) {
    +                   return null;
    +           }
    +
    +           // by default the factory class is the backend name 
    +           String factoryClassName = backendName;
    +
    +           switch (backendName.toLowerCase()) {
    --- End diff --
    
    This can be very hard to extend for somebody who wants to add an own 
backend, why not keep all creation encapsulated in a map under their string key 
and allow to add user mappings?


> Store Checkpoint Root Metadata in StateBackend (not in HA custom store)
> -----------------------------------------------------------------------
>
>                 Key: FLINK-5823
>                 URL: https://issues.apache.org/jira/browse/FLINK-5823
>             Project: Flink
>          Issue Type: Sub-task
>          Components: State Backends, Checkpointing
>            Reporter: Stephan Ewen
>            Assignee: Stephan Ewen
>            Priority: Blocker
>             Fix For: 1.5.0
>
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to