private void makeDoneSubdir(Path path) throws IOException { try { doneDirFc.getFileStatus(path); existingDoneSubdirs.add(path); } catch (FileNotFoundException fnfE) { try { FsPermission fsp = new FsPermission(JobHistoryUtils.HISTORY_DONE_DIR_PERMISSION); doneDirFc.mkdir(path, fsp, true); FileStatus fsStatus = doneDirFc.getFileStatus(path); /* LOG.info("Perms after creating "+fsStatus.getPermission().toShort()+", Expected: "+fsp.toShort()) */ LOG.perms_after_creating_expected( String.valueOf(fsStatus.getPermission().toShort()), String.valueOf(fsp.toShort())) .tag("methodCall") .info(); if (fsStatus.getPermission().toShort() != fsp.toShort()) { /* LOG.info("Explicitly setting permissions to : "+fsp.toShort()+", "+fsp) */ LOG.explicitly_setting_permissions(String.valueOf(fsp.toShort()), fsp.toString()) .tag("methodCall") .info(); doneDirFc.setPermission(path, fsp); } existingDoneSubdirs.add(path); } catch (FileAlreadyExistsException faeE) { // Nothing to do. } } }
public LogReader(Configuration conf, Path remoteAppLogFile) throws IOException { FileContext fileContext = FileContext.getFileContext(conf); this.fsDataIStream = fileContext.open(remoteAppLogFile); reader = new TFile.Reader( this.fsDataIStream, fileContext.getFileStatus(remoteAppLogFile).getLen(), conf); this.scanner = reader.createScanner(); }
boolean stopFileCreated() { try { fc.getFileStatus(flagFile); } catch (FileNotFoundException e) { return false; } catch (IOException e) { LOG.error("Got error when checking if file exists:" + flagFile, e); } LOG.info("Flag file was created. Stopping the test."); return true; }
private void mkdir(FileContext fc, Path path, FsPermission fsp) throws IOException { if (!fc.util().exists(path)) { try { fc.mkdir(path, fsp, true); FileStatus fsStatus = fc.getFileStatus(path); LOG.info( "Perms after creating " + fsStatus.getPermission().toShort() + ", Expected: " + fsp.toShort()); if (fsStatus.getPermission().toShort() != fsp.toShort()) { LOG.info("Explicitly setting permissions to : " + fsp.toShort() + ", " + fsp); fc.setPermission(path, fsp); } } catch (FileAlreadyExistsException e) { LOG.info("Directory: [" + path + "] already exists."); } } }
private void mkdir(FileContext fc, Path path, FsPermission fsp) throws IOException { if (!fc.util().exists(path)) { try { fc.mkdir(path, fsp, true); FileStatus fsStatus = fc.getFileStatus(path); /* LOG.info("Perms after creating "+fsStatus.getPermission().toShort()+", Expected: "+fsp.toShort()) */ LOG.perms_after_creating_expected( String.valueOf(fsStatus.getPermission().toShort()), String.valueOf(fsp.toShort())) .tag("methodCall") .info(); if (fsStatus.getPermission().toShort() != fsp.toShort()) { /* LOG.info("Explicitly setting permissions to : "+fsp.toShort()+", "+fsp) */ LOG.explicitly_setting_permissions(String.valueOf(fsp.toShort()), fsp.toString()) .tag("methodCall") .info(); fc.setPermission(path, fsp); } } catch (FileAlreadyExistsException e) { /* LOG.info("Directory: ["+path+"] already exists.") */ LOG.directory_already_exists(path.toString()).info(); } } }
// length of a file (path name) from NN. private long getFileLengthFromNN(Path path) throws IOException { FileStatus fileStatus = useFCOption ? mfc.getFileStatus(path) : mfs.getFileStatus(path); return fileStatus.getLen(); }