List of usage examples for org.apache.hadoop.fs FsShell close
public void close() throws IOException
From source file:com.blackberry.logdriver.LockedFsShell.java
License:Apache License
public static void main(String[] args) { // The required args are zkConnectString, dcNumber, service, date, hour, // component and an arbitrary number of commands. if (args.length < 7) { printUsage();//from ww w .j ava 2 s. c om System.exit(1); } String zkConnectString = args[0]; String dcNumber = args[1]; String service = args[2]; String date = args[3]; String hour = args[4]; String component = args[5]; // Set the configuration correctly, so we can reach zookeeper Configuration conf = new Configuration(); conf.set("zk.connect.string", zkConnectString); try { LockUtil lockUtil = new LockUtil(conf); PathInfo pathInfo = new PathInfo(); pathInfo.setDcNumber(dcNumber); pathInfo.setService(service); pathInfo.setDate(date); pathInfo.setHour(hour); pathInfo.setComponent(component); String lockPath = lockUtil.getLockPath(pathInfo); // Get the write lock while (true) { try { lockUtil.acquireWriteLock(lockPath); break; } catch (KeeperException.ConnectionLossException e) { LOG.warn("Lost connection to ZooKeeper. Retrying.", e); } } // Run the commands int res = 0; for (int i = 6; i < args.length; i++) { String[] fsShellArgs = args[i].split("\\s+"); LOG.info("Calling FsShell with args {}", args[i]); FsShell shell = new FsShell(); try { res = ToolRunner.run(shell, fsShellArgs); } finally { shell.close(); } if (res != 0) { break; } } // Release the write lock while (true) { try { lockUtil.releaseWriteLock(lockPath); break; } catch (KeeperException.ConnectionLossException e) { LOG.warn("Lost connection to ZooKeeper. Retrying.", e); } } if (res != 0) { LOG.error("Bad return value ({}) from FsShell", res); System.exit(res); } } catch (Exception e) { e.printStackTrace(); System.exit(1); } }
From source file:org.apache.solr.hadoop.HdfsFindTool.java
License:Apache License
public static void main(String argv[]) throws Exception { FsShell shell = new HdfsFindTool(); int res;/*from w w w .j a v a 2s .c om*/ try { res = ToolRunner.run(shell, argv); } finally { shell.close(); } System.exit(res); }