Example usage for org.apache.hadoop.fs LocalFileSystem LocalFileSystem

List of usage examples for org.apache.hadoop.fs LocalFileSystem LocalFileSystem

Introduction

In this page you can find the example usage for org.apache.hadoop.fs LocalFileSystem LocalFileSystem.

Prototype

public LocalFileSystem(FileSystem rawLocalFileSystem) 

Source Link

Usage

From source file:org.apache.lucene.cassandra.HadoopFile.java

License:Apache License

public HadoopFile(String canonicalPath) {
    // canonicalPath = "index1/thisfile";
    // TODO Auto-generated constructor stub
    logger.trace("File(String canonicalPath: {})", canonicalPath);

    // set default file system to local file system
    conf.set("fs.file.impl", "org.apache.hadoop.fs.LocalFileSystem");

    // must set a conf here to the underlying FS, or it barks
    RawLocalFileSystem rawLFS = new RawLocalFileSystem();
    rawLFS.setConf(conf);/*www  .jav  a  2  s  . co  m*/
    thePrivateFile = new LocalFileSystem(rawLFS);
    thePrivateFile.setVerifyChecksum(false);

    path = new Path(thePrivateFile.getWorkingDirectory(), canonicalPath);

    long length;
    try {
        length = thePrivateFile.getFileStatus(path).getLen();
        logger.info("length() {}", length);
        System.out.println("output file: " + path);
        System.out.println("exist: " + thePrivateFile.exists(path));
        logger.trace("thePrivateFile.getFileStatus {}", thePrivateFile.getFileStatus(path));

        if (!thePrivateFile.exists(path)) {
            thePrivateFile.create(path, true);
        } else {
            // thePrivateFile.create(path, true);
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    System.out.println("output file: " + path);
    System.out.println("output file: " + thePrivateFile.getWorkingDirectory());

}

From source file:org.apache.lucene.cassandra.HadoopFile.java

License:Apache License

public HadoopFile(File dir, String file) { // TODO create file in a directory.
    logger.trace("File(File dir  {}, String file {})", dir.getPath(), file);

    // set default file system to local file system
    conf.set("fs.file.impl", "org.apache.hadoop.fs.LocalFileSystem");

    // must set a conf here to the underlying FS, or it barks
    RawLocalFileSystem rawLFS = new RawLocalFileSystem();
    rawLFS.setConf(conf);//  w w w  .  ja va  2s. c o m
    thePrivateFile = new LocalFileSystem(rawLFS);
    thePrivateFile.setVerifyChecksum(false);
    path = new Path(dir.getPath() + "/" + file);
    try {
        if (!thePrivateFile.exists(path)) {
            thePrivateFile.create(path, true);
        } else {
            // thePrivateFile.create(path, true);
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    this.exists();

}

From source file:org.apache.lucene.cassandra.HadoopRandomAccessFile.java

License:Apache License

public HadoopRandomAccessFile(File dir, String mode) throws IOException {
    logger.trace("RandomAccessFile(File dir {}, String mode {})", dir.getPath(), mode);

    // set default file system to local file system
    conf.set("fs.file.impl", "org.apache.hadoop.fs.LocalFileSystem");

    // must set a conf here to the underlying FS, or it barks
    RawLocalFileSystem rawLFS = new RawLocalFileSystem();
    rawLFS.setConf(conf);/*from  ww  w. j  a v a  2  s  . co  m*/
    thePrivateFile = new LocalFileSystem(rawLFS);
    thePrivateFile.setVerifyChecksum(false);

    path = new Path(thePrivateFile.getWorkingDirectory(), dir.getPath());
    in = thePrivateFile.open(path);
    //        out = thePrivateFile.create(path, true);
    isOpen = true;

}