Ignore:
Timestamp:
2016-10-26T14:16:25+13:00 (7 years ago)
Author:
davidb
Message:

Moved to getFileSystemInstance() method to play nice on cluster

Location:
other-projects/hathitrust/solr-extracted-features/trunk/src/main/java/org/hathitrust
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • other-projects/hathitrust/solr-extracted-features/trunk/src/main/java/org/hathitrust/ClusterFileIO.java

    r30940 r30941  
    2525public class ClusterFileIO {
    2626
    27     protected static FileSystem _fs = null;
     27    private static FileSystem __fs = null;
    2828   
     29    /*
    2930    public static void initOLD(JavaSparkContext java_spark_context)
    3031    {
     
    3738        }
    3839    }
     40    */
    3941   
     42    /*
    4043    public static void init(String input_dir)
    4144    {
     
    5356       
    5457    }
     58    */
     59   
     60    public static FileSystem getFileSystemInstance(String input_dir)
     61    {
     62        if (__fs == null) {
     63
     64            try {
     65                Configuration conf = new Configuration();
     66                URI uri = new URI(input_dir);
     67                __fs = FileSystem.get(uri, conf);
     68            }
     69            catch (URISyntaxException e) {
     70                e.printStackTrace();   
     71            }
     72            catch (IOException e) {
     73                e.printStackTrace();
     74            }
     75        }
     76        return __fs;
     77    }
     78   
    5579    public static boolean isHDFS(String fileIn)
    5680    {
     
    6084    protected static boolean exists(String file)
    6185    {
     86        FileSystem fs = getFileSystemInstance(file);
     87       
    6288        //Configuration conf = jsc.hadoopConfiguration();
    6389        //FileSystem fs = org.apache.hadoop.fs.FileSystem.get(conf);
     
    6591       
    6692        try {
    67             exists = _fs.exists(new Path(file));
     93            exists = fs.exists(new Path(file));
    6894        } catch (IllegalArgumentException e) {
    6995            exists = false;
     
    77103            throws IOException
    78104    {
     105        FileSystem fs = getFileSystemInstance(fileIn);
     106       
    79107        BufferedInputStream bis = null;
    80108       
     
    86114           
    87115            //FSDataInputStream fin = _fs.open(new Path(fileIn));
    88             FSDataInputStream fin = _fs.open(new Path(uri));
     116            FSDataInputStream fin = fs.open(new Path(uri));
    89117           
    90118            bis = new BufferedInputStream(fin);
     
    101129            */
    102130           
    103             FSDataInputStream fin = _fs.open(new Path(fileIn));
     131            FSDataInputStream fin = fs.open(new Path(fileIn));
    104132           
    105133            bis = new BufferedInputStream(fin);
  • other-projects/hathitrust/solr-extracted-features/trunk/src/main/java/org/hathitrust/PrepareForIngest.java

    r30937 r30941  
    3636    {   
    3737        String spark_app_name = "HathiTrust Extract Features: Prepare for Solr Ingest";
    38         spark_app_name += "[" + _json_list_filename + "]";
     38        spark_app_name += " [" + _json_list_filename + "]";
    3939
    4040        SparkConf conf = new SparkConf().setAppName(spark_app_name);
    4141        JavaSparkContext jsc = new JavaSparkContext(conf);
    42         ClusterFileIO.init(_input_dir);
     42        //ClusterFileIO.init(_input_dir);
    4343       
    4444        // Check output directory exists, and create it if not
Note: See TracChangeset for help on using the changeset viewer.