Reputation: 157
I am currently migrating the old Arrow Filesystem Interface:
http://arrow.apache.org/docs/python/filesystems_deprecated.html
to the new Filesystem Interface:
http://arrow.apache.org/docs/python/filesystems.html
I am trying to connect to HDFS using fs.HadoopFileSystem as below
from pyarrow import fs
import os
os.environ['HADOOP_HOME'] = '/usr/hdp/current/hadoop-client'
os.environ['JAVA_HOME'] = '/opt/jdk8'
os.environ['ARROW_LIBHDFS_DIR'] = '/usr/lib/ams-hbase/lib/hadoop-native'
fs.HadoopFileSystem("hdfs://namenode:8020?user=hdfsuser")
I tried different combination of uri and also replaced uri with fs.HdfsOptions:
connection_tuple = ("namenode", 8020)
fs.HadoopFileSystem(fs.HdfsOptions(connection_tuple, user="hdfsuser"))
All of the above is throwing me the same error:
Environment variable CLASSPATH not set!
getJNIEnv: getGlobalJNIEnv failed
Environment variable CLASSPATH not set!
getJNIEnv: getGlobalJNIEnv failed
/arrow/cpp/src/arrow/filesystem/hdfs.cc:56: Failed to disconnect hdfs client: IOError: HDFS hdfsFS::Disconnect failed, errno: 255 (Unknown error 255) Please check that you are connecting to the correct HDFS RPC port
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pyarrow/_hdfs.pyx", line 180, in pyarrow._hdfs.HadoopFileSystem.__init__
File "pyarrow/error.pxi", line 122, in pyarrow.lib.pyarrow_internal_check_status
File "pyarrow/error.pxi", line 99, in pyarrow.lib.check_status
OSError: HDFS connection failed
There are not much documentation out there since this feature is quite new so hopefully I can get some answer here
Cheers
Upvotes: 5
Views: 11155
Reputation: 151
Set your HDFS classpath environment
export CLASSPATH=`$HADOOP_HOME/bin/hdfs classpath --glob`
locate the hdfs bin directory to set this variable
related question
Upvotes: 4