@Override public boolean containerExists(NamespaceKey key) { List<String> folderPath = key.getPathComponents(); try { return getFS(SystemUser.SYSTEM_USERNAME).exists(PathUtils.toFSPath( ImmutableList.<String>builder() .addAll(folderPath.subList(1, folderPath.size())) .build())); }catch(IOException e) { logger.info("IOException while trying to retrieve home files.", e); return false; } }
@Override public boolean datasetExists(NamespaceKey key) { final List<String> filePath = key.getPathComponents(); try { return getFS(SYSTEM_USERNAME).exists(PathUtils.toFSPath(resolveTableNameToValidPath(filePath))); } catch (IOException e) { logger.debug("Failure reading path.", e); return false; } }
/** * Create the supporting directory for this plugin if it doesn't yet exist. * @throws IOException */ private void createIfNecessary() throws IOException { if(!config.createIfMissing()) { return; } try { // no need to exists here as FileSystemWrapper does an exists check and this is a noop if already existing. fs.mkdirs(config.getPath()); } catch (IOException ex) { try { if(fs.exists(config.getPath())) { // race creation, ignore. return; } } catch (IOException existsFailure) { // we're doing the check above to detect a race condition. if we fail, ignore the failure and just fall through to throwing the originally caught exception. ex.addSuppressed(existsFailure); } throw new IOException(String.format("Failure to create directory %s.", config.getPath().toString()), ex); } }
private boolean hasChanged() throws IOException { final JobConf jobConf = new JobConf(hiveConf); for (Prop prop : HiveReaderProtoUtil.getPartitionProperties(tableXattr, updateKey.getPartitionId())) { jobConf.set(prop.getKey(), prop.getValue()); } Preconditions.checkArgument(updateKey.getCachedEntitiesCount() > 0, "hive partition update key should contain at least one path"); // create filesystem based on the first path which is root of the partition directory. final FileSystemWrapper fs = FileSystemWrapper.get(new Path(updateKey.getPartitionRootDir()), jobConf); for (FileSystemCachedEntity cachedEntity : updateKey.getCachedEntitiesList()) { final Path cachedEntityPath; if (cachedEntity.getPath() == null || cachedEntity.getPath().isEmpty()) { cachedEntityPath = new Path(updateKey.getPartitionRootDir()); } else { cachedEntityPath = new Path(updateKey.getPartitionRootDir(), cachedEntity.getPath()); } if (fs.exists(cachedEntityPath)) { final FileStatus fileStatus = fs.getFileStatus(cachedEntityPath); if (cachedEntity.getLastModificationTime() < fileStatus.getModificationTime()) { return true; } } else { return true; } } return false; } }
final FileSystemWrapper fs = FileSystemWrapper.get(rootLocation, job); if (fs.exists(rootLocation)) { final FileStatus rootStatus = fs.getFileStatus(rootLocation); if (rootStatus.isDirectory()) {
@Override public boolean createOrUpdateView(NamespaceKey key, View view, SchemaConfig schemaConfig) throws IOException { if(!getMutability().hasMutationCapability(MutationType.VIEW, schemaConfig.isSystemUser())) { throw UserException.parseError() .message("Unable to create view. Schema [%s] is immutable for this user.", key.getParent()) .build(logger); } Path viewPath = getViewPath(key.getPathComponents()); FileSystemWrapper fs = getFS(schemaConfig.getUserName()); boolean replaced = fs.exists(viewPath); final FsPermission viewPerms = new FsPermission(schemaConfig.getOption(ExecConstants.NEW_VIEW_DEFAULT_PERMS_KEY).getStringVal()); try (OutputStream stream = FileSystemWrapper.create(fs, viewPath, viewPerms)) { lpPersistance.getMapper().writeValue(stream, view); } return replaced; }
if(fs.exists(path)) { throw UserException.validationError().message("Folder already exists at path: %s.", key).build(logger);