Example usage for org.apache.hadoop.hdfs DistributedFileSystem close

List of usage examples for org.apache.hadoop.hdfs DistributedFileSystem close

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs DistributedFileSystem close.

Prototype

@Override
    public void close() throws IOException 

Source Link

Usage

From source file:tachyon.LocalMiniDFSCluster.java

License:Apache License

/**
 * Test the local minidfscluster only/*from  w w w  .  ja va 2 s . c om*/
 */
public static void main(String[] args) throws Exception {
    LocalMiniDFSCluster cluster = null;
    TachyonConf tachyonConf = new TachyonConf();
    try {
        cluster = new LocalMiniDFSCluster("/tmp/dfs", 1, 54321, tachyonConf);
        cluster.start();
        System.out.println("Address of local minidfscluster: " + cluster.getUnderFilesystemAddress());
        Thread.sleep(10);
        DistributedFileSystem dfs = cluster.getDFSClient();
        dfs.mkdirs(new Path("/1"));
        mkdirs(cluster.getUnderFilesystemAddress() + "/1/2", tachyonConf);
        FileStatus[] fs = dfs.listStatus(new Path(TachyonURI.SEPARATOR));
        assert fs.length != 0;
        System.out.println(fs[0].getPath().toUri());
        dfs.close();

        cluster.shutdown();

        cluster = new LocalMiniDFSCluster("/tmp/dfs", 3, tachyonConf);
        cluster.start();
        System.out.println("Address of local minidfscluster: " + cluster.getUnderFilesystemAddress());

        dfs = cluster.getDFSClient();
        dfs.mkdirs(new Path("/1"));

        CommonUtils.touch(cluster.getUnderFilesystemAddress() + "/1" + "/_format_" + System.currentTimeMillis(),
                tachyonConf);
        fs = dfs.listStatus(new Path("/1"));
        assert fs.length != 0;
        System.out.println(fs[0].getPath().toUri());
        dfs.close();

        cluster.shutdown();
    } finally {
        if (cluster != null && cluster.isStarted()) {
            cluster.shutdown();
        }
    }
}

From source file:tachyon.underfs.hdfs.LocalMiniDFSCluster.java

License:Apache License

/**
 * Test the local minidfscluster only/*from   www . jav a  2 s . c o  m*/
 */
public static void main(String[] args) throws Exception {
    LocalMiniDFSCluster cluster = null;
    TachyonConf tachyonConf = new TachyonConf();
    try {
        cluster = new LocalMiniDFSCluster("/tmp/dfs", 1, 54321, tachyonConf);
        cluster.start();
        System.out.println("Address of local minidfscluster: " + cluster.getUnderFilesystemAddress());
        Thread.sleep(10);
        DistributedFileSystem dfs = cluster.getDFSClient();
        dfs.mkdirs(new Path("/1"));
        mkdirs(cluster.getUnderFilesystemAddress() + "/1/2", tachyonConf);
        FileStatus[] fs = dfs.listStatus(new Path(TachyonURI.SEPARATOR));
        assert fs.length != 0;
        System.out.println(fs[0].getPath().toUri());
        dfs.close();

        cluster.shutdown();

        cluster = new LocalMiniDFSCluster("/tmp/dfs", 3, tachyonConf);
        cluster.start();
        System.out.println("Address of local minidfscluster: " + cluster.getUnderFilesystemAddress());

        dfs = cluster.getDFSClient();
        dfs.mkdirs(new Path("/1"));

        UnderFileSystemUtils.touch(
                cluster.getUnderFilesystemAddress() + "/1" + "/_format_" + System.currentTimeMillis(),
                tachyonConf);
        fs = dfs.listStatus(new Path("/1"));
        assert fs.length != 0;
        System.out.println(fs[0].getPath().toUri());
        dfs.close();

        cluster.shutdown();
    } finally {
        if (cluster != null && cluster.isStarted()) {
            cluster.shutdown();
        }
    }
}