@Override public void run() { try { LOG.debug("Checking master is serving requests"); FileSystem fs = FileSystem.Factory.get(mConf); fs.exists(new AlluxioURI("/")); LOG.debug("Master is serving requests"); } catch (Throwable e) { throw new RuntimeException(e); } } }
@Override public void check(FileSystem fs) throws Exception { Assert.assertFalse(fs.exists(SRC)); Assert.assertTrue(fs.exists(DST)); Assert.assertFalse(fs.exists(new AlluxioURI("/renameDir/a"))); Assert.assertTrue(fs.exists(new AlluxioURI("/renameDir/c"))); Assert.assertTrue(fs.exists(new AlluxioURI("/renameDir/c/b"))); } }
@Override public void check(FileSystem fs) throws Exception { for (AlluxioURI deleted : Arrays.asList(PATH, NESTED, RECURSIVE)) { assertFalse(fs.exists(deleted)); } assertTrue(fs.exists(NESTED.getParent())); assertFalse(fs.exists(RECURSIVE.getParent())); assertTrue(fs.exists(RECURSIVE.getParent().getParent())); } }
AlluxioURI checkURI = new AlluxioURI(workDir + s); if (ClientOpType.CREATE_FILE == opType) { if (!sFileSystem.exists(checkURI)) { if (sFileSystem.exists(checkURI)) { LOG.error("File exists for create/delete test. Check failed! File: {}", checkURI); return false; if (!sFileSystem.exists(new AlluxioURI(checkURI + "-rename"))) {
/** * Writes a file. * * @param count the count to determine the filename * @throws Exception if it fails to write */ private static void writeFile(CyclicBarrier barrier, AtomicLong runtime, int count, AlluxioConfiguration alluxioConf) throws Exception { FileSystem fileSystem = FileSystem.Factory.get(alluxioConf); byte[] buffer = new byte[(int) Math.min(sFileSize, 4 * Constants.MB)]; Arrays.fill(buffer, (byte) 'a'); AlluxioURI path = filename(count); if (fileSystem.exists(path)) { fileSystem.delete(path); } barrier.await(); long startTime = System.nanoTime(); long bytesWritten = 0; try (FileOutStream outStream = fileSystem.createFile(path)) { while (bytesWritten < sFileSize) { outStream.write(buffer, 0, (int) Math.min(buffer.length, sFileSize - bytesWritten)); bytesWritten += buffer.length; } } runtime.addAndGet(System.nanoTime() - startTime); }
&& mFileSystem.exists(mPath) && mFileSystem.getStatus(mPath).isFolder() && mFileSystem.listStatus(mPath).isEmpty()) {
if (!fs.exists(uri)) { LOG.debug("The file {} being waited upon does not exist yet. Waiting for it to be " + "created.", uri);
@Override public int run(CommandLine cl) throws AlluxioException, IOException { String[] args = cl.getArgs(); AlluxioURI srcPath = new AlluxioURI(args[0]); AlluxioURI dstPath = new AlluxioURI(args[1]); if (mFileSystem.exists(dstPath)) { throw new RuntimeException(dstPath + " already exists"); } Thread thread = JobGrpcClientUtils.createProgressThread(2 * Constants.SECOND_MS, System.out); thread.start(); try { JobGrpcClientUtils.run(new MoveConfig(srcPath.getPath(), dstPath.getPath(), null, true), 3, mFsContext.getConf()); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return -1; } finally { thread.interrupt(); } System.out.println("Moved " + srcPath + " to " + dstPath); return 0; }
DeletePOptions deleteOptions = DeletePOptions.newBuilder().setAlluxioOnly(true).build(); mFileSystem.delete(inconsistentUri, deleteOptions); mFileSystem.exists(inconsistentUri); System.out.println(inconsistentUri + " repaired"); System.out.println(); System.out.println("repairing path: " + uri); mFileSystem.delete(uri, deleteOptions); mFileSystem.exists(uri); System.out.println(uri + "repaired"); System.out.println();
@Override public void check(FileSystem fs) throws Exception { Assert.assertTrue(fs.getStatus(ALLUXIO_MOUNT_PATH).isMountPoint()); Assert.assertFalse(fs.exists(ALLUXIO_UNMOUNT_PATH)); } }
@Override protected void runPlainPath(AlluxioURI path, CommandLine cl) throws AlluxioException, IOException { // TODO(calvin): Remove explicit state checking. boolean recursive = cl.hasOption("R"); if (!mFileSystem.exists(path)) { throw new FileDoesNotExistException(ExceptionMessage.PATH_DOES_NOT_EXIST.getMessage(path)); } if (!recursive && mFileSystem.getStatus(path).isFolder()) { throw new IOException( path.getPath() + " is a directory, to remove it, please use \"rm -R <path>\""); } boolean isAlluxioOnly = cl.hasOption(REMOVE_ALLUXIO_ONLY.getLongOpt()); DeletePOptions options = DeletePOptions.newBuilder().setRecursive(recursive).setAlluxioOnly(isAlluxioOnly) .setUnchecked(cl.hasOption(REMOVE_UNCHECKED_OPTION_CHAR)).build(); mFileSystem.delete(path, options); if (!isAlluxioOnly) { System.out.println(path + " has been removed"); } else { System.out.println(path + " has been removed from Alluxio space"); } }
@Override public FSDataOutputStream append(Path path, int bufferSize, Progressable progress) throws IOException { LOG.debug("append({}, {}, {})", path, bufferSize, progress); if (mStatistics != null) { mStatistics.incrementWriteOps(1); } AlluxioURI uri = new AlluxioURI(HadoopUtils.getPathWithoutScheme(path)); try { if (mFileSystem.exists(uri)) { throw new IOException(ExceptionMessage.FILE_ALREADY_EXISTS.getMessage(uri)); } return new FSDataOutputStream( mFileSystem.createFile(uri, CreateFilePOptions.newBuilder().setRecursive(true).build()), mStatistics); } catch (AlluxioException e) { throw new IOException(e); } }
@Override public boolean setReplication(Path path, short replication) throws IOException { AlluxioURI uri = new AlluxioURI(HadoopUtils.getPathWithoutScheme(path)); try { if (!mFileSystem.exists(uri) || mFileSystem.getStatus(uri).isFolder()) { return false; } mFileSystem.setAttribute(uri, (SetAttributePOptions) SetAttributePOptions.newBuilder() .setReplicationMin(replication).build()); return true; } catch (AlluxioException e) { throw new IOException(e); } }
private void checkUploadId(AlluxioURI multipartTemporaryDir, long uploadId) throws S3Exception { try { if (!mFileSystem.exists(multipartTemporaryDir)) { throw new S3Exception(multipartTemporaryDir.getPath(), S3ErrorCode.NO_SUCH_UPLOAD); } long tmpDirId = mFileSystem.getStatus(multipartTemporaryDir).getFileId(); if (uploadId != tmpDirId) { throw new S3Exception(multipartTemporaryDir.getPath(), S3ErrorCode.NO_SUCH_UPLOAD); } } catch (Exception e) { throw toObjectS3Exception(e, multipartTemporaryDir.getPath()); } }
@Override public void check(FileSystem fs) throws Exception { for (AlluxioURI file : Arrays.asList(PATH, NESTED, THROUGH, TTL)) { assertTrue(fs.exists(file)); } assertEquals(TEST_MODE, new Mode((short) fs.getStatus(MODE).getMode())); assertTrue(fs.getStatus(THROUGH).isPersisted()); assertEquals(TEST_TTL, fs.getStatus(TTL).getTtl()); assertEquals(TtlAction.FREE, fs.getStatus(TTL).getTtlAction()); } }
private FileOutStream createFile(FileSystem fileSystem, AlluxioURI filePath, boolean deleteIfExists) throws IOException, AlluxioException { CreateFilePOptions options = CreateFilePOptions.newBuilder().setWriteType(mWriteType.toProto()) .setRecursive(true).build(); if (!fileSystem.exists(filePath)) { // file doesn't exist yet, so create it return fileSystem.createFile(filePath, options); } else if (deleteIfExists) { // file exists, so delete it and recreate fileSystem.delete(filePath); return fileSystem.createFile(filePath, options); } // file exists and deleteIfExists is false throw new FileAlreadyExistsException("File exists and deleteIfExists is false"); }
if (mFileSystem.exists(uri)) { if (!overwrite) { throw new IOException(ExceptionMessage.FILE_ALREADY_EXISTS.getMessage(uri));
FileSystem fs = FileSystem.Factory.get(fsContext); if (fs.exists(testDir)) { fs.delete(testDir, DeletePOptions.newBuilder().setRecursive(true).setUnchecked(true).build());
@Override public void check(FileSystem fs) throws Exception { for (AlluxioURI dir : Arrays.asList(DIR, NESTED_DIR, NESTED_NESTED_DIR, RECURSIVE, MODE_DIR, TTL_DIR, COMMON_TTL_DIR, THROUGH_DIR, ALL_OPTS_DIR)) { assertTrue(fs.exists(dir)); } assertEquals(TEST_MODE, new Mode((short) fs.getStatus(MODE_DIR).getMode())); assertEquals((long) TTL, fs.getStatus(TTL_DIR).getTtl()); assertEquals(alluxio.grpc.TtlAction.DELETE, fs.getStatus(TTL_DIR).getTtlAction()); assertEquals((long) TTL, fs.getStatus(COMMON_TTL_DIR).getTtl()); assertEquals(alluxio.grpc.TtlAction.DELETE, fs.getStatus(COMMON_TTL_DIR).getTtlAction()); assertTrue(fs.getStatus(THROUGH_DIR).isPersisted()); assertEquals(TEST_MODE, new Mode((short) fs.getStatus(ALL_OPTS_DIR).getMode())); assertEquals((long) TTL, fs.getStatus(ALL_OPTS_DIR).getTtl()); assertEquals(alluxio.grpc.TtlAction.DELETE, fs.getStatus(ALL_OPTS_DIR).getTtlAction()); assertTrue(fs.getStatus(ALL_OPTS_DIR).isPersisted()); } }