Skip to content

Instantly share code, notes, and snippets.

@dallasmarlow
Created October 14, 2013 16:47
Show Gist options
  • Save dallasmarlow/6978574 to your computer and use it in GitHub Desktop.
Save dallasmarlow/6978574 to your computer and use it in GitHub Desktop.
jruby hdfs client
#!/usr/bin/env jruby
include Java
options = {
hdfs_uri: 'hdfs://0.0.0.0:8020/',
hadoop_config_path: '/etc/hadoop/conf',
hadoop_config_files: ['core-site.xml', 'hdfs-site.xml'],
}
hdfs_conf = org.apache.hadoop.conf.Configuration.new
hdfs_uri = java.net.URI.create options[:hdfs_uri]
# add hdfs config from local machine
options[:hadoop_config_files].each do |config_file|
hdfs_conf.add_resource org.apache.hadoop.fs.Path.new File.join options[:hadoop_config_path], config_file
end
hdfs = org.apache.hadoop.fs.FileSystem.get hdfs_uri, hdfs_conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment