/** * Waits for a condition to be satisfied. * * @param description a description of what causes condition to evaluate to true * @param condition the condition to wait on * @throws TimeoutException if the function times out while waiting for the condition to be true */ public static void waitFor(String description, Supplier<Boolean> condition) throws InterruptedException, TimeoutException { waitFor(description, condition, WaitForOptions.defaults()); }
/** * Gets size. * * @return the file size */ public String getSize() { if (mIsDirectory) { return ""; } else { return FormatUtils.getSizeFromBytes(mSize); } }
/** * @return a session ID */ public static long createSessionId() { return getRandomNonNegativeLong(); }
@Test(expected = TimeoutException.class) public void waitForTimeout() throws Exception { CountCondition cond = new CountCondition(100); WaitForOptions opts = WaitForOptions.defaults().setInterval(3).setTimeoutMs(100); CommonUtils.waitFor("", cond, opts); } }
/** * @return the default instance of {@link WaitForOptions} */ public static WaitForOptions defaults() { return new WaitForOptions().setInterval(DEFAULT_INTERVAL).setTimeoutMs(NEVER); }
/** * Gets creation time. * * @param dateFormatPattern the pattern to use when formatting the timestamp * @return the creation time (in milliseconds) */ public String getCreationTime(String dateFormatPattern) { if (mCreationTimeMs == UIFileInfo.LocalFileInfo.EMPTY_CREATION_TIME) { return ""; } return CommonUtils.convertMsToDate(mCreationTimeMs, dateFormatPattern); }
/** * Checks if security is enabled. * * @param conf Alluxio configuration * @return true if security is enabled, false otherwise */ public static boolean isSecurityEnabled(AlluxioConfiguration conf) { return isAuthenticationEnabled(conf) && isAuthorizationEnabled(conf); }
/** * Applies the default umask for newly created files to this mode. * * @param mode the mode to update * @param authUmask the umask to apply on the file * @return the updated object */ public static Mode applyFileUMask(Mode mode, String authUmask) { mode = applyUMask(mode, getUMask(authUmask)); mode = applyUMask(mode, FILE_UMASK); return mode; }
@Override public boolean supportsPath(String path) { if (path == null) { return false; } return URIUtils.isLocalFilesystem(path); } }
/** * @return the built Unix mount info */ public UnixMountInfo build() { return new UnixMountInfo(mDeviceSpec, mMountPoint, mFsType, mOptions); } }
ReadRequest(long id, long start, long end, long chunkSize) { mId = id; mStart = start; mEnd = end; mChunkSize = chunkSize; mSessionId = IdUtils.createSessionId(); }
/** * @return the built Unix mount info options */ public Options build() { return new Options(mSize); } }
/** * Gets capacity. * * @return the capacity */ public String getCapacity() { return FormatUtils.getSizeFromBytes(mCapacityBytes); }
/** * @return a session id used internally in workers */ public static long createInternalSessionId() { return INTERNAL_SESSION_ID_BASE - IdUtils.getRandomNonNegativeLong() % (Long.MAX_VALUE + INTERNAL_SESSION_ID_BASE); } }
/** * Gets modification time. * * @param dateFormatPattern the pattern to use when formatting the timestamp * @return the modification time (in milliseconds) */ public String getModificationTime(String dateFormatPattern) { return CommonUtils.convertMsToDate(mLastModificationTimeMs, dateFormatPattern); }
/** * Gets capacity. * * @return the worker capacity in bytes */ public String getCapacity() { return FormatUtils.getSizeFromBytes(mCapacityBytes); }
/** * @return a random long which is guaranteed to be non negative (zero is allowed) */ public static long createMountId() { return getRandomNonNegativeLong(); }
/** * Gets start time. * * @return the start time */ public String getStartTime() { return CommonUtils.convertMsToDate(mStartTimeMs, mDateFormatPattern); }
/** * Gets free capacity. * * @return the free capacity */ public String getFreeCapacity() { return FormatUtils.getSizeFromBytes(mFreeBytes); }
/** * Gets used capacity. * * @return the used capacity */ public String getUsedCapacity() { return FormatUtils.getSizeFromBytes(mUsedBytes); }