/** * @return whether the stream is open */ public boolean isOpen() { try (LockResource lr = new LockResource(mLock)) { return !mClosed && !mCanceled && mError == null; } }
@Override public final State getState() { try (LockResource lr = new LockResource(mStateLock)) { return mState; } }
/** * @return the set of threads present in the scheduler */ public static Set<String> getThreadNames() { try (LockResource r = new LockResource(sLock)) { return sTimers.keySet(); } }
@Override public final void waitForState(State state) throws InterruptedException { try (LockResource lr = new LockResource(mStateLock)) { while (mState != state) { mStateCond.await(); } } } }
/** * Removes a timer name from the scheduler if it exists. * * @param name the name to clear */ public static void clearTimer(String name) { try (LockResource r = new LockResource(sLock)) { sTimers.remove(name); } }
/** * @param clazz the class of the {@link Server} to add * @param server the {@link Server} to add * @param <W> the type of the {@link Server} to add */ public <W extends T> void add(Class<W> clazz, T server) { try (LockResource r = new LockResource(mLock)) { mRegistry.put(clazz, server); } }
protected final void setState(State state) { try (LockResource lr = new LockResource(mStateLock)) { mState = state; mStateCond.signalAll(); synchronized (mListeners) { mListeners.forEach(listener -> listener.get().accept(state)); } LOG.info("Primary selector transitioning to {}", state); } }
/** * Returns a copy of the current mount table, the mount table is a map from Alluxio file system * URIs to the corresponding mount point information. * * @return a copy of the current mount table */ public Map<String, MountInfo> getMountTable() { try (LockResource r = new LockResource(mReadLock)) { return new HashMap<>(mState.getMountTable()); } }
/** * Constructs a {@link MasterJournalContext}. * * @param asyncJournalWriter a {@link AsyncJournalWriter} * @param lock a lock to hold until the context is closed */ public RaftJournalContext(AsyncJournalWriter asyncJournalWriter, Lock lock) { mLockResource = new LockResource(lock); mContext = new MasterJournalContext(asyncJournalWriter); }
@Override public BlockMeta getVolatileBlockMeta(long blockId) throws BlockDoesNotExistException { LOG.debug("getVolatileBlockMeta: blockId={}", blockId); try (LockResource r = new LockResource(mMetadataReadLock)) { return mMetaManager.getBlockMeta(blockId); } }
@Override public TempBlockMeta getTempBlockMeta(long sessionId, long blockId) { LOG.debug("getTempBlockMeta: sessionId={}, blockId={}", sessionId, blockId); try (LockResource r = new LockResource(mMetadataReadLock)) { return mMetaManager.getTempBlockMetaOrNull(blockId); } }
@Override public boolean hasBlockMeta(long blockId) { LOG.debug("hasBlockMeta: blockId={}", blockId); try (LockResource r = new LockResource(mMetadataReadLock)) { return mMetaManager.hasBlockMeta(blockId); } }
@Override public BlockStoreMeta getBlockStoreMeta() { // Removed DEBUG logging because this is very noisy // LOG.debug("getBlockStoreMeta:"); BlockStoreMeta storeMeta; try (LockResource r = new LockResource(mMetadataReadLock)) { storeMeta = mMetaManager.getBlockStoreMeta(); } return storeMeta; }
/** * Clears all the mount points except the root. */ public void reset() { LOG.info("Clearing mount table (except the root)."); try (LockResource r = new LockResource(mWriteLock)) { mState.reset(); } }
/** * Acquires the lock for modifying an inode's last modified time or size. As a pre-requisite, the * current thread should already hold a read lock on the inode. * * @param inodeId the id of the inode to lock * @return a lock resource which must be closed to release the lock */ public LockResource lockUpdate(long inodeId) { return new LockResource(mParentUpdateLocks.get(inodeId)); } }
/** * @param uri an Alluxio path URI * @return whether the given uri is a mount point */ public boolean isMountPoint(AlluxioURI uri) { try (LockResource r = new LockResource(mReadLock)) { return mState.getMountTable().containsKey(uri.getPath()); } }
@Override public BlockMeta getBlockMeta(long sessionId, long blockId, long lockId) throws BlockDoesNotExistException, InvalidWorkerStateException { LOG.debug("getBlockMeta: sessionId={}, blockId={}, lockId={}", sessionId, blockId, lockId); mLockManager.validateLock(sessionId, blockId, lockId); try (LockResource r = new LockResource(mMetadataReadLock)) { return mMetaManager.getBlockMeta(blockId); } }
@Override public JournalContext createJournalContext() throws UnavailableException { // All modifications to journaled state must happen inside of a journal context so that we can // persist the state change. As a mechanism to allow for state pauses, we acquire the state // change lock before entering any code paths that could modify journaled state. try (LockResource l = new LockResource(mMasterContext.stateChangeLock())) { return mJournal.createJournalContext(); } } }
public void onReady() { try (LockResource lr = new LockResource(mLock)) { if (shouldRestartDataReader()) { mDataReaderExecutor.submit(createDataReader(mContext, mResponseObserver)); mContext.setDataReaderActive(true); } } }
@Override public BlockReader getBlockReader(long sessionId, long blockId, long lockId) throws BlockDoesNotExistException, InvalidWorkerStateException, IOException { LOG.debug("getBlockReader: sessionId={}, blockId={}, lockId={}", sessionId, blockId, lockId); mLockManager.validateLock(sessionId, blockId, lockId); try (LockResource r = new LockResource(mMetadataReadLock)) { BlockMeta blockMeta = mMetaManager.getBlockMeta(blockId); return new LocalFileBlockReader(blockMeta.getPath()); } }