Christian Tooley
11/05/2024, 10:21 PMflink-s3-fs-hadoop I get the error Caused by: org.apache.hadoop.fs.UnsupportedFileSystemException: No FileSystem for scheme "file" when sinking to S3 (source works fine). I have the hadoop package added to my pom.xml, & have the pyflink looking at my pyflink-dependencies.jar
table_env.get_config().get_configuration().set_string(
"pipeline.jars",
"file:///" + ROOT_DIR + "/target/pyflink-dependencies.jar",
)
I've also tried the other plugin flink-s3-fs-presto which does give me an output, but it doesn't exit after the output and eventually (~1-2m later) gives me the error unable to execute http request: read timed out
Any suggestions? I've even tried AWS's example repo which seems to have the same error https://github.com/aws-samples/amazon-managed-service-for-apache-flink-examples/tree/main/python/S3Sink
Apache-flink 1.20.0Andreas Bube
11/06/2024, 7:36 AMNo FileSystem for scheme "file" suggests your loading a file using the file:// schema. You can try adding the flink-connector-files dependency (https://mvnrepository.com/artifact/org.apache.flink/flink-connector-files/1.20.0) to your pom
The details are a bit fuzzy since it's been a while since we set up our project, so take my advice pinch of salt. The flink dist comes with many of the core dependencies bundled in the /lib. These are all present on the classpath then running flink binary form the cli. They are, however, not present on the classpath when running the main() from your IDE/maven. Add these missing dependencies with their scope set to provided.Andreas Bube
11/06/2024, 7:37 AMAndreas Bube
11/06/2024, 7:38 AMTo make the applications run within IntelliJ IDEA, it is necessary to tick thebox in the run configuration. If this option is not available (possibly due to using an older IntelliJ IDEA version), then a workaround is to create a test that calls the application’sInclude dependencies with "Provided" scopemethod.main()
Christian Tooley
11/06/2024, 2:12 PMflink-connector-files to my pom but the error persists. I'll attach the stacktrace here, but it is weird, it looks like it's within the s3a connector code, before trying to create a local directory.
I'm also not using any local files within the application, besides my requirements.txt and flink dependency setup, e.g,
ROOT_DIR = str(pathlib.Path(__file__).parent.parent.parent)
table_env.set_python_requirements(
requirements_file_path="file:///" + ROOT_DIR + "/requirements.txt"
)
is_local = True if os.environ.get("IS_LOCAL") else False
if is_local:
table_env.get_config().get_configuration().set_string(
"pipeline.jars",
"file:///" + ROOT_DIR + "/target/pyflink-dependencies.jar",
)Christian Tooley
11/06/2024, 2:12 PMChristian Tooley
11/06/2024, 2:13 PMpython main.py within my virtual environmentChristian Tooley
11/06/2024, 2:45 PMChristian Tooley
11/06/2024, 3:08 PMtable_env.get_config().get_configuration().set_string(
"fs.hdfs.hadoopconf", "file:///" + ROOT_DIR + "/core-site.xml"
)
core-site.xml:
<configuration>
<!-- Define the default filesystem scheme -->
<property>
<name>fs.defaultFS</name>
<value>file:///</value>
</property>
<!-- Specify the local file system implementation class -->
<property>
<name>fs.file.impl</name>
<value>org.apache.hadoop.fs.LocalFileSystem</value>
</property>
<!-- Define any local temporary directory if needed -->
<property>
<name>hadoop.tmp.dir</name>
<value>/tmp/hadoop-temp</value>
</property>
</configuration>Andreas Bube
11/07/2024, 8:22 AMmvn package in order to build the fat jar (pyflink-dependencies.jar) that contains the required dependencies. Did you do that already?
```# For local development (only): use the fat-jar containing all dependencies, generated bymvn package
# located in the target/ subdirectory
"file:///" + CURRENT_DIR + "/target/pyflink-dependencies.jar"```(https://github.com/aws-samples/amazon-managed-service-for-apache-flink-examples/bl[…]/c6efcc1e2e41fee0c6401022e6d21fcb0a665ba3/python/S3Sink/main.py)
Andreas Bube
11/07/2024, 8:51 AMif("local".equals(StreamExecutionEnvironment.getExecutionEnvironment().getConfiguration().get(DeploymentOptions.TARGET))) {
Configuration config = ...
// When running Flink locally, the file systems are initialized with an empty Flink configuration. This occurs
// because Flink's file system is designed to operate with cluster-level configuration and is initialized before
// the pipeline. By the time main() is invoked, the file systems have already been initialized. To work around
// this issue, we re-initialize the file system with our provided configuration. Credentials for the Hadoop S3
// file system are affected by this.
// Reference: https://lists.apache.org/thread/95pssrz2y4rhjgwp4tgnvsp1qjzbpv6w
FileSystem.initialize(config, null);
}Andreas Bube
11/07/2024, 11:14 AMfile://, so I imagine that something funny is happening while maven is creating the fat dependency jar. Something similar to this old stackoverflow question: https://stackoverflow.com/questions/17265002/hadoop-no-filesystem-for-scheme-file