Example usage for org.apache.hadoop.fs FileSystem closeAll

List of usage examples for org.apache.hadoop.fs FileSystem closeAll

Introduction

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

Prototype

public static void closeAll() throws IOException 

Source Link

Document

Close all cached FileSystem instances.

Usage

From source file:org.apache.ignite.internal.processors.hadoop.impl.fs.HadoopFileSystemsUtils.java

License:Apache License

/**
 * Clears Hadoop {@link FileSystem} cache.
 *
 * @throws IOException On error./*from  w ww . ja v  a  2 s  .  c o m*/
 */
public static void clearFileSystemCache() throws IOException {
    FileSystem.closeAll();
}

From source file:org.apache.kudu.mapreduce.HadoopTestingUtility.java

License:Apache License

public void cleanup() throws IOException {
    FileSystem.closeAll();
    if (this.testDir != null) {
        delete(this.testDir);
    }//from w  w  w .jav a 2s . c o m
}

From source file:org.apache.phoenix.hive.HiveTestUtil.java

License:Apache License

public void shutdown() throws Exception {
    cleanUp();/*from w  w  w .j a v  a2s . c om*/
    setup.tearDown();
    if (mr != null) {
        mr.shutdown();
        mr = null;
    }
    FileSystem.closeAll();
    if (dfs != null) {
        dfs.shutdown();
        dfs = null;
    }
}

From source file:org.apache.solr.hadoop.MorphlineGoLiveMiniMRTest.java

License:Apache License

@AfterClass
public static void teardownClass() throws Exception {
    System.clearProperty("solr.hdfs.blockcache.enabled");
    if (mrCluster != null) {
        mrCluster.shutdown();//  ww w  .  j a v a 2  s . c  o  m
        mrCluster = null;
    }
    if (dfsCluster != null) {
        dfsCluster.shutdown();
        dfsCluster = null;
    }
    FileSystem.closeAll();
}

From source file:org.commoncrawl.service.crawler.CrawlerEngine.java

License:Open Source License

public void stopCrawlerCleanly() {
    LOG.info("Clean Shutdown - Stopping Crawl");
    stopCrawl(new CrawlStopCallback() {

        public void crawlStopped() {
            LOG.info("Clean Shutdown - Crawl Stopped. Stopping Server");
            _server.stop();/*from   w  ww .j ava  2s  .  c  o m*/
            LOG.info("Clean Shutdown - Stopping Hadoop");
            try {
                FileSystem.closeAll();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            LOG.info("Clean Shutdown - Exiting App");
            System.exit(1);

        }

    });
}

From source file:org.lilyproject.hadooptestfw.HBaseProxy.java

License:Apache License

public void stop() throws Exception {
    if (mode == Mode.EMBED) {
        // Since HBase mini cluster shutdown has a tendency of sometimes failing (hanging waiting on master
        // to end), add a protection for this so that we do not run indefinitely. Especially important not to
        // annoy the other projects on our Hudson server.
        Thread stopHBaseThread = new Thread() {
            @Override//from  www .  ja v a  2  s  . c o  m
            public void run() {
                try {
                    hbaseTestUtil.shutdownMiniCluster();
                    hbaseTestUtil = null;
                } catch (Exception e) {
                    System.out.println("Error shutting down mini cluster.");
                    e.printStackTrace();
                }
            }
        };
        stopHBaseThread.start();
        stopHBaseThread.join(60000);
        if (stopHBaseThread.isAlive()) {
            System.err.println("Unable to stop embedded mini cluster within predetermined timeout.");
            System.err.println("Dumping stack for future investigation.");
            ReflectionUtils.printThreadInfo(new PrintWriter(System.out), "Thread dump");
            System.out.println(
                    "Will now try to interrupt the mini-cluster-stop-thread and give it some more time to end.");
            stopHBaseThread.interrupt();
            stopHBaseThread.join(20000);
            throw new Exception("Failed to stop the mini cluster within the predetermined timeout.");
        }
    }

    // Close connections with HBase and HBase's ZooKeeper handles
    //HConnectionManager.deleteConnectionInfo(CONF, true);
    HConnectionManager.deleteAllConnections(true);

    // Close all HDFS connections
    FileSystem.closeAll();

    conf = null;

    if (clearData && testHome != null) {
        TestHomeUtil.cleanupTestHome(testHome);
    }

    ManagementFactory.getPlatformMBeanServer()
            .unregisterMBean(new ObjectName("LilyHBaseProxy:name=ReplicationPeer"));
}

From source file:org.springframework.data.hadoop.fs.FileSystemFactoryBean.java

License:Apache License

public void destroy() throws Exception {
    if (fs != null && close) {
        fs.close();/*from  w  ww .j  a v a2 s  . c o m*/
    }
    fs = null;

    if (closeAll) {
        // TODO: potentially call close all just for the current user
        FileSystem.closeAll();
    }
}

From source file:org.wso2.carbon.hdfs.dataaccess.DataAccessService.java

License:Open Source License

/**
 * Close all file system connections.
 * @throws IOException
 */
public void unmountAllFileSystems() throws IOException {
    FileSystem.closeAll();
}

From source file:pack.block.blockstore.hdfs.HdfsMiniClusterUtil.java

License:Apache License

public static void shutdownDfs(MiniDFSCluster cluster) {
    if (cluster != null) {
        LOGGER.info("Shutting down Mini DFS");
        try {//from   w w  w  .  j  a va2  s.  c  om
            cluster.shutdown();
        } catch (Exception e) {
            // / Can get a java.lang.reflect.UndeclaredThrowableException thrown
            // here because of an InterruptedException. Don't let exceptions in
            // here be cause of test failure.
        }
        try {
            FileSystem fs = cluster.getFileSystem();
            if (fs != null) {
                LOGGER.info("Shutting down FileSystem");
                fs.close();
            }
            FileSystem.closeAll();
        } catch (IOException e) {
            LOGGER.error("error closing file system", e);
        }

        // This has got to be one of the worst hacks I have ever had to do.
        // This is needed to shutdown 2 thread pools that are not shutdown by
        // themselves.
        ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
        Thread[] threads = new Thread[100];
        int enumerate = threadGroup.enumerate(threads);
        for (int i = 0; i < enumerate; i++) {
            Thread thread = threads[i];
            if (thread.getName().startsWith("pool")) {
                if (thread.isAlive()) {
                    thread.interrupt();
                    LOGGER.info("Stopping ThreadPoolExecutor {}", thread.getName());
                    Object target = getField(Thread.class, thread, "target");
                    if (target != null) {
                        ThreadPoolExecutor e = (ThreadPoolExecutor) getField(ThreadPoolExecutor.class, target,
                                "this$0");
                        if (e != null) {
                            e.shutdownNow();
                        }
                    }
                    try {
                        LOGGER.info("Waiting for thread pool to exit {}", thread.getName());
                        thread.join();
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }
    }
}