List of usage examples for org.apache.hadoop.fs FileContext setPermission
public void setPermission(final Path f, final FsPermission permission) throws AccessControlException, FileNotFoundException, UnsupportedFileSystemException, IOException
From source file:com.ikanow.aleph2.core.shared.utils.DirUtils.java
License:Apache License
/** Creates a directory in the storage servce * @param fileContext//from www .j ava 2 s . c o m * @param pathString */ public static void createDirectory(FileContext fileContext, String pathString) { if (fileContext != null && pathString != null) { try { Path dir = new Path(pathString); if (!fileContext.util().exists(dir)) { fileContext.mkdir(dir, DEFAULT_DIR_PERMS, true); //(note perm is & with umask) try { fileContext.setPermission(dir, DEFAULT_DIR_PERMS); } catch (Exception e) { } // (not supported in all FS) } } catch (Exception e) { logger.error("createFolderStructure Caught Exception", e); } } }
From source file:com.ikanow.aleph2.management_db.services.DataBucketCrudService.java
License:Apache License
/** Create the different default files needed by the bucket in the distributed file system * @param bucket//from w w w . j av a 2 s. co m * @param storage_service * @throws Exception */ public static void createFilePaths(final DataBucketBean bucket, final IStorageService storage_service) throws Exception { final FileContext dfs = storage_service.getUnderlyingPlatformDriver(FileContext.class, Optional.empty()) .get(); final String bucket_root = storage_service.getBucketRootPath() + "/" + bucket.full_name(); // Check if a "delete touch file is present, bail if so" if (doesBucketPathExist(bucket, storage_service, Optional.of(DELETE_TOUCH_FILE))) { throw new RuntimeException( ErrorUtils.get(ManagementDbErrorUtils.DELETE_TOUCH_FILE_PRESENT, bucket.full_name())); } Arrays.asList("", "logs", "logs/harvest", "logs/enrichment", "logs/storage", "assets", "import", "import/temp", "import/temp/upload", "import/transient", "import/stored", "import/stored/raw", "import/stored/json", "import/stored/processed", "import/ready").stream() .map(s -> new Path(bucket_root + IStorageService.BUCKET_SUFFIX + s)) .forEach(Lambdas.wrap_consumer_u(p -> { dfs.mkdir(p, DEFAULT_DIR_PERMS, true); //(note perm is & with umask) try { dfs.setPermission(p, DEFAULT_DIR_PERMS); } catch (Exception e) { } // (not supported in all FS) })); }