private static FsPath ParameterOrConfigured(FsPath path, Configuration config, ConfigOption <string> option)
        {
            if (path != null)
            {
                return(path);
            }

            var configValue = config.GetString(option);

            try
            {
                return(configValue == null ? null : new FsPath(configValue));
            }
            catch (IllegalArgumentException)
            {
                throw new IllegalConfigurationException("Cannot parse value for " + option.Key +
                                                        " : " + configValue + " . Not a valid path.");
            }
        }
        private static FsPath ValidatePath(FsPath path)
        {
            var scheme   = path.Scheme;
            var pathPart = path.Path;

            // some validity checks
            if (scheme == null)
            {
                throw new IllegalArgumentException("The scheme (hdfs://, file://, etc) is null. " +
                                                   "Please specify the file system scheme explicitly in the URI.");
            }
            if (pathPart == null)
            {
                throw new IllegalArgumentException("The path to store the checkpoint data in is null. " +
                                                   "Please specify a directory path for the checkpoint data.");
            }
            if (pathPart.Length == 0 || pathPart.Equals("/"))
            {
                throw new IllegalArgumentException("Cannot use the root directory for checkpoints.");
            }

            return(path);
        }
 protected AbstractFileStateBackend(FsPath baseCheckpointPath, FsPath baseSavepointPath, Configuration configuration)
 {
     BaseCheckpointPath = baseCheckpointPath == null ? null : ParameterOrConfigured(baseCheckpointPath, configuration, CheckpointingOptions.CheckpointsDirectory);
     BaseSavepointPath  = baseSavepointPath == null ? null : ValidatePath(baseSavepointPath);
 }
 /// <summary>
 /// Creates a backend with the given optional checkpoint- and savepoint base directories.
 /// </summary>
 /// <param name="baseCheckpointPath">The base directory for checkpoints, or null, if none is configured.</param>
 /// <param name="baseSavepointPath">The default directory for savepoints, or null, if none is set.</param>
 protected AbstractFileStateBackend(FsPath baseCheckpointPath = default, FsPath baseSavepointPath = default)
 {
     BaseCheckpointPath = baseCheckpointPath == null ? null : ValidatePath(baseCheckpointPath);
     BaseSavepointPath  = baseSavepointPath == null ? null : ValidatePath(baseSavepointPath);
 }