/** * Constructs a new exception with the specified exception message, the cause and multiple * parameters. * * @param message the exception message * @param cause the cause * @param params the parameters */ public InvalidWorkerStateException(ExceptionMessage message, Throwable cause, Object... params) { this(message.getMessage(params), cause); } }
/** * Constructs a new exception with the specified exception message, the cause and multiple * parameters. * * @param message the exception message * @param cause the cause * @param params the parameters */ public BlockInfoException(ExceptionMessage message, Throwable cause, Object... params) { this(message.getMessage(params), cause); } }
/** * Constructs a new exception with the specified exception message, the cause and multiple * parameters. * * @param message the exception message * @param cause the cause * @param params the parameters */ public ConnectionFailedException(ExceptionMessage message, Throwable cause, Object... params) { this(message.getMessage(params), cause); } }
/** * Constructs a new exception with the specified exception message, the cause and multiple * parameters. * * @param message the exception message * @param cause the cause * @param params the parameters */ public BlockAlreadyExistsException(ExceptionMessage message, Throwable cause, Object... params) { this(message.getMessage(params), cause); } }
/** * Constructs a new exception with the specified exception message and multiple parameters. * * @param message the exception message * @param params the parameters */ public FileAlreadyExistsException(ExceptionMessage message, Object... params) { this(message.getMessage(params)); }
/** * Constructs a new exception with the specified exception message, the cause and multiple * parameters. * * @param message the exception message * @param cause the cause * @param params the parameters */ public JobDoesNotExistException(ExceptionMessage message, Throwable cause, Object... params) { this(message.getMessage(params), cause); }
/** * Constructs a new exception saying the specified job ID does not exist. * * @param jobId the job id which does not exit */ public JobDoesNotExistException(long jobId) { this(ExceptionMessage.JOB_DOES_NOT_EXIST.getMessage(jobId)); } }
@Override public double getDouble(PropertyKey key) { String rawValue = get(key); try { return Double.parseDouble(rawValue); } catch (NumberFormatException e) { throw new RuntimeException(ExceptionMessage.KEY_NOT_DOUBLE.getMessage(key)); } }
@Override public boolean getBoolean(PropertyKey key) { String rawValue = get(key); if (rawValue.equalsIgnoreCase("true")) { return true; } else if (rawValue.equalsIgnoreCase("false")) { return false; } else { throw new RuntimeException(ExceptionMessage.KEY_NOT_BOOLEAN.getMessage(key)); } }
public void write(JournalEntry entry) throws IOException { if (mClosed) { throw new IOException(ExceptionMessage.JOURNAL_WRITE_AFTER_CLOSE.getMessage()); } try { entry.toBuilder().setSequenceNumber(mNextSequenceNumber).build() .writeDelimitedTo(mTmpCheckpointStream); } catch (IOException e) { throw e; } mNextSequenceNumber++; }
/** * @return the target inode as an {@link MutableInodeFile} * @throws FileDoesNotExistException if the target inode does not exist, or it is not a file */ public InodeFile getInodeFile() throws FileDoesNotExistException { Inode inode = getInode(); if (!inode.isFile()) { throw new FileDoesNotExistException(ExceptionMessage.PATH_MUST_BE_FILE.getMessage(mUri)); } return inode.asFile(); }
@Override public void masterRegister(long masterId, RegisterMasterPOptions options) throws NotFoundException { MasterInfo master = mMasters.getFirstByField(ID_INDEX, masterId); if (master == null) { throw new NotFoundException(ExceptionMessage.NO_MASTER_FOUND.getMessage(masterId)); } master.updateLastUpdatedTimeMs(); mMasterConfigStore.registerNewConf(master.getAddress(), options.getConfigsList()); LOG.info("registerMaster(): master: {}", master); }
@Test public void moveToSubpath() throws Exception { try { assignMovesFail("/src", "/src/dst"); } catch (RuntimeException e) { Assert.assertEquals( ExceptionMessage.MOVE_CANNOT_BE_TO_SUBDIRECTORY.getMessage("/src", "/src/dst"), e.getMessage()); } }
@Test public void checkNoFallThroughFromGroupToOther() throws Exception { mThrown.expect(AccessControlException.class); mThrown.expectMessage(ExceptionMessage.PERMISSION_DENIED.getMessage( toExceptionMessage(TEST_USER_3.getUser(), Mode.Bits.WRITE, TEST_WEIRD_FILE_URI, "testWeirdFile"))); // group cannot write although other can checkPermission(TEST_USER_3, Mode.Bits.WRITE, TEST_WEIRD_FILE_URI); }
@Test public void selfCheckFailBySameGroup() throws Exception { mThrown.expect(AccessControlException.class); mThrown.expectMessage(ExceptionMessage.PERMISSION_DENIED.getMessage( toExceptionMessage(TEST_USER_3.getUser(), Mode.Bits.WRITE, TEST_DIR_FILE_URI, "file"))); // not the owner but in same group checkPermission(TEST_USER_3, Mode.Bits.WRITE, TEST_DIR_FILE_URI); }
/** * Tests user1 to create directories under root. */ @Test public void createUnderRootFail() throws Exception { mThrown.expect(AccessControlException.class); mThrown.expectMessage(ExceptionMessage.PERMISSION_DENIED .getMessage(toExceptionMessage(TEST_USER_1.getUser(), Mode.Bits.WRITE, "/file1", "/"))); // create "/file1" for user1 verifyCreateFile(TEST_USER_1, "/file1", false); }
@Test public void mkdirUnderRootByUser() throws Exception { mThrown.expect(AccessControlException.class); mThrown.expectMessage(ExceptionMessage.PERMISSION_DENIED .getMessage(toExceptionMessage(TEST_USER_1.getUser(), Mode.Bits.WRITE, "/dir1", "/"))); // createDirectory "/dir1" for user1 verifyCreateDirectory(TEST_USER_1, "/dir1", false); }
@Test public void moveFileToExistingDestinationWithoutOverwrite() throws Exception { createFile("/src"); createFile("/dst"); // Test with source being a file. try { assignMovesFail("/src", "/dst"); } catch (FileAlreadyExistsException e) { Assert.assertEquals(ExceptionMessage.MOVE_NEED_OVERWRITE.getMessage("/dst"), e.getMessage()); } }
@Test public void readDirIdFail() throws Exception { String dir = createUnreadableFileOrDir(false); mThrown.expect(AccessControlException.class); mThrown.expectMessage(ExceptionMessage.PERMISSION_DENIED.getMessage( toExceptionMessage(TEST_USER_2.getUser(), Mode.Bits.READ, dir, "onlyReadByUser1"))); verifyGetFileId(TEST_USER_2, dir); }
/** * Tests {@link FileSystemMaster#free} on non-persisted file. */ @Test public void freeNonPersistedFile() throws Exception { createFileWithSingleBlock(NESTED_FILE_URI); mThrown.expect(UnexpectedAlluxioException.class); mThrown.expectMessage(ExceptionMessage.CANNOT_FREE_NON_PERSISTED_FILE .getMessage(NESTED_FILE_URI.getPath())); // cannot free a non-persisted file mFileSystemMaster.free(NESTED_FILE_URI, FreeContext.defaults()); }