Example usage for org.apache.hadoop.fs HarFileSystem getConf

List of usage examples for org.apache.hadoop.fs HarFileSystem getConf

Introduction

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

Prototype

@Override
    public Configuration getConf() 

Source Link

Usage

From source file:com.dianping.cat.hadoop.hdfs.HarConnectionPool.java

License:Open Source License

public HarFileSystem getHarfsConnection(String id, Date date, FileSystem fs) throws IOException {
    String serverUri = m_serverConfigManager.getHarfsServerUri(id);
    String baseUri = m_serverConfigManager.getHarfsBaseDir(id);
    String harUri = m_format.format(new Object[] { serverUri, baseUri, date });
    Pair<HarFileSystem, Long> har = m_hars.get(harUri);
    long current = System.currentTimeMillis();

    if (har == null) {
        synchronized (this) {
            if (har == null) {

                URI uri = URI.create(harUri);
                HarFileSystem harfs = new HarFileSystem(fs);

                try {
                    harfs.initialize(uri, harfs.getConf());
                    har = new Pair<HarFileSystem, Long>(harfs, current);

                    m_hars.put(harUri, har);
                } catch (IOException e) {
                    // ignore
                }//from   ww  w  .ja  v a 2s  .  c  om
            }
        }
    }

    if (har != null) {
        har.setValue(current);
        return har.getKey();
    } else {
        return null;
    }
}