idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
12,300
public synchronized void handleNodeLost ( Address address ) { Preconditions . checkNotNull ( address , "address should not be null" ) ; mLostNodes . add ( address ) ; for ( Runnable function : mChangeListeners ) { function . run ( ) ; } }
Updates configuration when a live node becomes lost .
12,301
public synchronized void lostNodeFound ( Address address ) { Preconditions . checkNotNull ( address , "address should not be null" ) ; mLostNodes . remove ( address ) ; for ( Runnable function : mChangeListeners ) { function . run ( ) ; } }
Updates configuration when a lost node is found .
12,302
public synchronized void addTask ( int taskId ) { Preconditions . checkArgument ( ! mTaskIdToInfo . containsKey ( taskId ) , "" ) ; mTaskIdToInfo . put ( taskId , new TaskInfo ( ) . setJobId ( mId ) . setTaskId ( taskId ) . setStatus ( Status . CREATED ) . setErrorMessage ( "" ) . setResult ( null ) ) ; }
Registers a task .
12,303
public void start ( ) throws Exception { mJournalSystem . start ( ) ; mJournalSystem . gainPrimacy ( ) ; startMaster ( true ) ; startServing ( ) ; }
Starts the Alluxio job master server .
12,304
public static URI appendPath ( URI base , String path ) throws URISyntaxException { return new URI ( base . getScheme ( ) , base . getAuthority ( ) , PathUtils . concatPath ( base . getPath ( ) , path ) , base . getQuery ( ) , base . getFragment ( ) ) ; }
Appends the given path to the given base URI .
12,305
public static Map < String , String > parseQueryString ( String query ) { Map < String , String > queryMap = new HashMap < > ( ) ; if ( query == null || query . isEmpty ( ) ) { return queryMap ; } String [ ] entries = query . split ( String . valueOf ( QUERY_SEPARATOR ) ) ; try { for ( String entry : entries ) { String...
Parses the given query string and returns a map of the query parameters .
12,306
public static int hash ( int hash , String s ) { if ( s == null ) { return hash ; } return s . indexOf ( '%' ) < 0 ? 31 * hash + s . hashCode ( ) : normalizedHash ( hash , s ) ; }
Hashes a string for a URI hash . Handles octets .
12,307
public static int hashIgnoreCase ( int hash , String s ) { if ( s == null ) { return hash ; } int length = s . length ( ) ; for ( int i = 0 ; i < length ; i ++ ) { hash = 31 * hash + URIUtils . toLower ( s . charAt ( i ) ) ; } return hash ; }
Hashes a string for a URI hash while ignoring the case .
12,308
public static boolean isAuthenticationEnabled ( AlluxioConfiguration conf ) { return ! conf . getEnum ( PropertyKey . SECURITY_AUTHENTICATION_TYPE , AuthType . class ) . equals ( AuthType . NOSASL ) ; }
Checks if authentication is enabled .
12,309
public static void main ( String [ ] args ) { if ( args . length != 0 ) { LOG . info ( "java -cp {} {}" , RuntimeConstants . ALLUXIO_JAR , AlluxioWorkerMonitor . class . getCanonicalName ( ) ) ; LOG . warn ( "ignoring arguments" ) ; } AlluxioConfiguration conf = new InstancedConfiguration ( ConfigurationUtils . default...
Starts the Alluxio worker monitor .
12,310
private static String computeTargetPath ( String path , String source , String destination ) throws Exception { String relativePath = PathUtils . subtractPaths ( path , source ) ; return PathUtils . concatPath ( destination , relativePath ) ; }
Computes the path that the given path should end up at when source is migrated to destination .
12,311
public static String generateDbPath ( String baseDir , String dbName ) { return PathUtils . concatPath ( baseDir , dbName ) ; }
Generates a path to use for a RocksDB database .
12,312
protected ObjectStatus getObjectStatus ( String key ) { try { FileInfo fileInfo = mKodoClinet . getFileInfo ( key ) ; if ( fileInfo == null ) { return null ; } return new ObjectStatus ( key , fileInfo . hash , fileInfo . fsize , fileInfo . putTime / 10000 ) ; } catch ( QiniuException e ) { LOG . warn ( "Failed to get O...
Gets metadata information about object . Implementations should process the key as is which may be a file or a directory key .
12,313
static int interpretOrdinal ( int ordinal , int numTiers ) { if ( ordinal >= 0 ) { return Math . min ( ordinal , numTiers - 1 ) ; } return Math . max ( numTiers + ordinal , 0 ) ; }
Interprets a tier ordinal given the number of tiers .
12,314
public void addBlock ( String tierAlias , long blockId , long blockSize , long blockLastAccessTimeMs ) { UIFileBlockInfo block = new UIFileBlockInfo ( blockId , blockSize , blockLastAccessTimeMs , tierAlias , mAlluxioConfiguration ) ; List < UIFileBlockInfo > blocksOnTier = mBlocksOnTier . get ( tierAlias ) ; if ( bloc...
Adds a block to the file information .
12,315
public String getCreationTime ( ) { if ( mCreationTimeMs == UIFileInfo . LocalFileInfo . EMPTY_CREATION_TIME ) { return "" ; } return CommonUtils . convertMsToDate ( mCreationTimeMs , mAlluxioConfiguration . get ( PropertyKey . USER_DATE_FORMAT_PATTERN ) ) ; }
Gets creation time .
12,316
public Map < String , Integer > getOnTierPercentages ( ) { return mOrderedTierAliases . stream ( ) . collect ( Collectors . toMap ( tier -> tier , tier -> { Long sizeOnTier = mSizeOnTier . getOrDefault ( tier , 0L ) ; return mSize > 0 ? ( int ) ( 100 * sizeOnTier / mSize ) : 0 ; } ) ) ; }
Gets on - tier percentages .
12,317
private void chgrp ( AlluxioURI path , String group , boolean recursive ) throws AlluxioException , IOException { SetAttributePOptions options = SetAttributePOptions . newBuilder ( ) . setGroup ( group ) . setRecursive ( recursive ) . build ( ) ; mFileSystem . setAttribute ( path , options ) ; System . out . println ( ...
Changes the group for the directory or file with the path specified in args .
12,318
public int transferTo ( ByteBuf buf ) throws IOException { Preconditions . checkState ( ! mClosed ) ; if ( mUnderFileSystemInputStream == null ) { return - 1 ; } if ( mBlockMeta . getBlockSize ( ) <= mInStreamPos ) { return - 1 ; } ByteBuf bufCopy = null ; if ( mBlockWriter != null ) { bufCopy = buf . duplicate ( ) ; b...
This interface is supposed to be used for sequence block reads .
12,319
public void close ( ) throws IOException { if ( mClosed ) { return ; } try { updateBlockWriter ( mBlockMeta . getBlockSize ( ) ) ; if ( mUnderFileSystemInputStream != null ) { mUfsInstreamManager . release ( mUnderFileSystemInputStream ) ; mUnderFileSystemInputStream = null ; } if ( mBlockWriter != null ) { mBlockWrite...
Closes the block reader . After this this block reader should not be used anymore . This is recommended to be called after the client finishes reading the block . It is usually triggered when the client unlocks the block .
12,320
private void updateUnderFileSystemInputStream ( long offset ) throws IOException { if ( ( mUnderFileSystemInputStream != null ) && offset != mInStreamPos ) { mUfsInstreamManager . release ( mUnderFileSystemInputStream ) ; mUnderFileSystemInputStream = null ; mInStreamPos = - 1 ; } if ( mUnderFileSystemInputStream == nu...
Updates the UFS input stream given an offset to read .
12,321
private void cancelBlockWriter ( ) throws IOException { if ( mBlockWriter == null ) { return ; } try { mBlockWriter . close ( ) ; mBlockWriter = null ; mLocalBlockStore . abortBlock ( mBlockMeta . getSessionId ( ) , mBlockMeta . getBlockId ( ) ) ; } catch ( BlockDoesNotExistException e ) { LOG . warn ( "Block {} does n...
Closes the current block writer cleans up its temp block and sets it to null .
12,322
private void updateBlockWriter ( long offset ) throws IOException { if ( mBlockWriter != null && offset > mBlockWriter . getPosition ( ) ) { cancelBlockWriter ( ) ; } try { if ( mBlockWriter == null && offset == 0 && ! mBlockMeta . isNoCache ( ) ) { BlockStoreLocation loc = BlockStoreLocation . anyDirInTier ( mStorageT...
Updates the block writer given an offset to read . If the offset is beyond the current position of the block writer the block writer will be aborted .
12,323
protected void runWildCardCmd ( AlluxioURI wildCardPath , CommandLine cl ) throws IOException { List < AlluxioURI > paths = FileSystemShellUtils . getAlluxioURIs ( mFileSystem , wildCardPath ) ; if ( paths . size ( ) == 0 ) { throw new IOException ( wildCardPath + " does not exist." ) ; } paths . sort ( Comparator . co...
Runs the command for a particular URI that may contain wildcard in its path .
12,324
public GrpcServer start ( ) throws IOException { RetryUtils . retry ( "Starting gRPC server" , ( ) -> mServer . start ( ) , new ExponentialBackoffRetry ( 100 , 500 , 5 ) ) ; mStarted = true ; return this ; }
Start serving .
12,325
private MasterWorkerInfo registerWorkerInternal ( long workerId ) { for ( IndexedSet < MasterWorkerInfo > workers : Arrays . asList ( mTempWorkers , mLostWorkers ) ) { MasterWorkerInfo worker = workers . getFirstByField ( ID_INDEX , workerId ) ; if ( worker == null ) { continue ; } synchronized ( worker ) { worker . up...
Re - register a lost worker or complete registration after getting a worker id .
12,326
@ GuardedBy ( "workerInfo" ) private void processWorkerRemovedBlocks ( MasterWorkerInfo workerInfo , Collection < Long > removedBlockIds ) { for ( long removedBlockId : removedBlockIds ) { try ( LockResource lr = lockBlock ( removedBlockId ) ) { Optional < BlockMeta > block = mBlockStore . getBlock ( removedBlockId ) ;...
Updates the worker and block metadata for blocks removed from a worker .
12,327
@ GuardedBy ( "workerInfo" ) private void processWorkerAddedBlocks ( MasterWorkerInfo workerInfo , Map < String , List < Long > > addedBlockIds ) { for ( Map . Entry < String , List < Long > > entry : addedBlockIds . entrySet ( ) ) { for ( long blockId : entry . getValue ( ) ) { try ( LockResource lr = lockBlock ( bloc...
Updates the worker and block metadata for blocks added to a worker .
12,328
@ GuardedBy ( "masterBlockInfo" ) private Optional < BlockInfo > generateBlockInfo ( long blockId ) throws UnavailableException { if ( mSafeModeManager . isInSafeMode ( ) ) { throw new UnavailableException ( ExceptionMessage . MASTER_IN_SAFEMODE . getMessage ( ) ) ; } BlockMeta block ; List < BlockLocation > blockLocat...
Generates block info including worker locations for a block id .
12,329
private Set < MasterWorkerInfo > selectInfoByAddress ( Set < String > addresses , Set < MasterWorkerInfo > workerInfoSet , Set < String > workerNames ) { return workerInfoSet . stream ( ) . filter ( info -> { String host = info . getWorkerAddress ( ) . getHost ( ) ; workerNames . add ( host ) ; String ip = null ; try {...
Selects the MasterWorkerInfo from workerInfoSet whose host or related IP address exists in addresses .
12,330
public void write ( WriteRequest writeRequest ) { if ( ! tryAcquireSemaphore ( ) ) { return ; } mSerializingExecutor . execute ( ( ) -> { try { if ( mContext == null ) { LOG . debug ( "Received write request {}." , writeRequest ) ; mContext = createRequestContext ( writeRequest ) ; } else { Preconditions . checkState (...
Handles write request .
12,331
public void writeDataMessage ( WriteRequest request , DataBuffer buffer ) { if ( buffer == null ) { write ( request ) ; return ; } Preconditions . checkState ( ! request . hasCommand ( ) , "write request command should not come with data buffer" ) ; Preconditions . checkState ( buffer . readableBytes ( ) > 0 , "invalid...
Handles write request with data message .
12,332
public void onCompleted ( ) { mSerializingExecutor . execute ( ( ) -> { Preconditions . checkState ( mContext != null ) ; try { completeRequest ( mContext ) ; replySuccess ( ) ; } catch ( Exception e ) { LogUtils . warnWithException ( LOG , "Exception occurred while completing write request {}." , mContext . getRequest...
Handles request complete event .
12,333
public void onCancel ( ) { mSerializingExecutor . execute ( ( ) -> { try { cancelRequest ( mContext ) ; replyCancel ( ) ; } catch ( Exception e ) { LogUtils . warnWithException ( LOG , "Exception occurred while cancelling write request {}." , mContext . getRequest ( ) , e ) ; Throwables . throwIfUnchecked ( e ) ; abort...
Handles request cancellation event .
12,334
public void onError ( Throwable cause ) { if ( cause instanceof StatusRuntimeException && ( ( StatusRuntimeException ) cause ) . getStatus ( ) . getCode ( ) == Status . Code . CANCELLED ) { return ; } mSerializingExecutor . execute ( ( ) -> { LogUtils . warnWithException ( LOG , "Exception thrown while handling write r...
Handles errors from the request .
12,335
@ GuardedBy ( "mLock" ) private void validateWriteRequest ( alluxio . grpc . WriteRequest request ) throws InvalidArgumentException { if ( request . hasCommand ( ) && request . getCommand ( ) . hasOffset ( ) && request . getCommand ( ) . getOffset ( ) != mContext . getPos ( ) ) { throw new InvalidArgumentException ( St...
Validates a block write request .
12,336
private void abort ( Error error ) { try { if ( mContext == null || mContext . getError ( ) != null || mContext . isDoneUnsafe ( ) ) { return ; } mContext . setError ( error ) ; cleanupRequest ( mContext ) ; replyError ( ) ; } catch ( Exception e ) { LOG . warn ( "Failed to cleanup states with error {}." , e . getMessa...
Abort the write process due to error .
12,337
private void replyError ( ) { Error error = Preconditions . checkNotNull ( mContext . getError ( ) ) ; if ( error . isNotifyClient ( ) ) { mResponseObserver . onError ( error . getCause ( ) . toGrpcStatusException ( ) ) ; } }
Writes an error response .
12,338
public void send ( ReqT request , long timeoutMs ) throws IOException { if ( mClosed || mCanceled || mClosedFromRemote ) { throw new CancelledException ( formatErrorMessage ( "Failed to send request %s: stream is already closed or canceled." , request ) ) ; } try ( LockResource lr = new LockResource ( mLock ) ) { while...
Sends a request . Will wait until the stream is ready before sending or timeout if the given timeout is reached .
12,339
public void send ( ReqT request ) throws IOException { if ( mClosed || mCanceled || mClosedFromRemote ) { throw new CancelledException ( formatErrorMessage ( "Failed to send request %s: stream is already closed or canceled." , request ) ) ; } try ( LockResource lr = new LockResource ( mLock ) ) { checkError ( ) ; } mRe...
Sends a request . Will not wait for the stream to be ready .
12,340
public ResT receive ( long timeoutMs ) throws IOException { if ( mCompleted ) { return null ; } if ( mCanceled ) { throw new CancelledException ( formatErrorMessage ( "Stream is already canceled." ) ) ; } try { Object response = mResponses . poll ( timeoutMs , TimeUnit . MILLISECONDS ) ; if ( response == null ) { throw...
Receives a response from the server . Will wait until a response is received or throw an exception if times out .
12,341
public void cancel ( ) { if ( isOpen ( ) ) { LOG . debug ( "Cancelling stream ({})" , mDescription ) ; mCanceled = true ; mRequestObserver . cancel ( "Request is cancelled by user." , null ) ; } }
Cancels the stream .
12,342
public static void main ( String [ ] args ) { if ( args . length != 0 ) { LOG . info ( "java -cp {} {}" , RuntimeConstants . ALLUXIO_JAR , AlluxioJobMasterMonitor . class . getCanonicalName ( ) ) ; LOG . warn ( "ignoring arguments" ) ; } AlluxioConfiguration conf = new InstancedConfiguration ( ConfigurationUtils . defa...
Starts the Alluxio job_master monitor .
12,343
private void load ( AlluxioURI filePath , boolean local ) throws AlluxioException , IOException { URIStatus status = mFileSystem . getStatus ( filePath ) ; if ( status . isFolder ( ) ) { List < URIStatus > statuses = mFileSystem . listStatus ( filePath ) ; for ( URIStatus uriStatus : statuses ) { AlluxioURI newPath = n...
Loads a file or directory in Alluxio space makes it resident in Alluxio .
12,344
public void closeReaderOrWriter ( long sessionId , long blockId ) throws IOException { BlockInfo blockInfo ; try ( LockResource lr = new LockResource ( mLock ) ) { blockInfo = mBlocks . get ( new Key ( sessionId , blockId ) ) ; if ( blockInfo == null ) { LOG . warn ( "Key (block ID: {}, session ID {}) is not found when...
Closes the block reader or writer and checks whether it is necessary to commit the block to Local block store .
12,345
public BlockReader getBlockReader ( final long sessionId , long blockId , long offset ) throws BlockDoesNotExistException , IOException { final BlockInfo blockInfo ; try ( LockResource lr = new LockResource ( mLock ) ) { blockInfo = getBlockInfo ( sessionId , blockId ) ; BlockReader blockReader = blockInfo . getBlockRe...
Creates a block reader that reads from UFS and optionally caches the block to the Alluxio block store .
12,346
synchronized long getNewDirectoryId ( JournalContext context ) throws UnavailableException { initialize ( context ) ; long containerId = mNextDirectoryId . getContainerId ( ) ; long sequenceNumber = mNextDirectoryId . getSequenceNumber ( ) ; long directoryId = BlockId . createBlockId ( containerId , sequenceNumber ) ; ...
Returns the next directory id and journals the state .
12,347
public static < T > String listToString ( List < T > list ) { StringBuilder sb = new StringBuilder ( ) ; for ( T s : list ) { if ( sb . length ( ) != 0 ) { sb . append ( " " ) ; } sb . append ( s ) ; } return sb . toString ( ) ; }
Converts a list of objects to a string .
12,348
public static < T > String argsToString ( String separator , T ... args ) { StringBuilder sb = new StringBuilder ( ) ; for ( T s : args ) { if ( sb . length ( ) != 0 ) { sb . append ( separator ) ; } sb . append ( s ) ; } return sb . toString ( ) ; }
Converts varargs of objects to a string .
12,349
public static String randomAlphaNumString ( int length ) { StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < length ; i ++ ) { sb . append ( ALPHANUM . charAt ( RANDOM . nextInt ( ALPHANUM . length ( ) ) ) ) ; } return sb . toString ( ) ; }
Generates a random alphanumeric string of the given length .
12,350
public static < T > T createNewClassInstance ( Class < T > cls , Class < ? > [ ] ctorClassArgs , Object [ ] ctorArgs ) { try { if ( ctorClassArgs == null ) { return cls . newInstance ( ) ; } Constructor < T > ctor = cls . getConstructor ( ctorClassArgs ) ; return ctor . newInstance ( ctorArgs ) ; } catch ( InvocationTa...
Creates new instance of a class by calling a constructor that receives ctorClassArgs arguments .
12,351
public static List < String > getUnixGroups ( String user ) throws IOException { String result ; List < String > groups = new ArrayList < > ( ) ; try { result = ShellUtils . execCommand ( ShellUtils . getGroupsForUserCommand ( user ) ) ; } catch ( ExitCodeException e ) { LOG . warn ( "got exception trying to get groups...
Gets the current user s group list from Unix by running the command groups NOTE . For non - existing user it will return EMPTY list . This method may return duplicate groups .
12,352
public static < T > T waitForResult ( String description , Supplier < T > operation , WaitForOptions options ) throws InterruptedException , TimeoutException { T t ; long start = System . currentTimeMillis ( ) ; int interval = options . getInterval ( ) ; int timeout = options . getTimeoutMs ( ) ; while ( ( t = operatio...
Waits for an operation to return a non - null value with a specified timeout .
12,353
public static String getPrimaryGroupName ( String userName , AlluxioConfiguration conf ) throws IOException { List < String > groups = getGroups ( userName , conf ) ; return ( groups != null && groups . size ( ) > 0 ) ? groups . get ( 0 ) : "" ; }
Gets the primary group name of a user .
12,354
public static String stripSuffixIfPresent ( final String key , final String suffix ) { if ( key . endsWith ( suffix ) ) { return key . substring ( 0 , key . length ( ) - suffix . length ( ) ) ; } return key ; }
Strips the suffix if it exists . This method will leave keys without a suffix unaltered .
12,355
public static Throwable getRootCause ( Throwable e ) { while ( e . getCause ( ) != null && ! ( e . getCause ( ) instanceof StatusRuntimeException ) ) { e = e . getCause ( ) ; } return e ; }
Gets the root cause of an exception . It stops at encountering gRPC s StatusRuntimeException .
12,356
public static < T > Iterator < T > singleElementIterator ( final T element ) { return new Iterator < T > ( ) { private boolean mHasNext = true ; public boolean hasNext ( ) { return mHasNext ; } public T next ( ) { if ( ! hasNext ( ) ) { throw new NoSuchElementException ( ) ; } mHasNext = false ; return element ; } publ...
Returns an iterator that iterates on a single element .
12,357
public static RuntimeException closeAndRethrow ( Closer closer , Throwable t ) throws IOException { try { throw closer . rethrow ( t ) ; } finally { closer . close ( ) ; } }
Closes the Closer and re - throws the Throwable . Any exceptions thrown while closing the Closer will be added as suppressed exceptions to the Throwable . This method always throws the given Throwable wrapping it in a RuntimeException if it s a non - IOException checked exception .
12,358
public static String convertMsToDate ( long millis , String dateFormatPattern ) { DateFormat dateFormat = new SimpleDateFormat ( dateFormatPattern ) ; return dateFormat . format ( new Date ( millis ) ) ; }
Converts a millisecond number to a formatted date String .
12,359
private static Map < Tag , String > createTags ( String ufsName , UfsStatus status ) { Map < Tag , String > tagMap = new HashMap < > ( ) ; tagMap . put ( Tag . UFS , ufsName ) ; tagMap . put ( Tag . OWNER , status . getOwner ( ) ) ; tagMap . put ( Tag . GROUP , status . getGroup ( ) ) ; tagMap . put ( Tag . MODE , Stri...
Parses the input status and returns a tag map .
12,360
public boolean isValid ( ) { if ( mValues . isEmpty ( ) ) { return false ; } for ( Tag tag : REQUIRED_TAGS ) { if ( ! mValues . containsKey ( tag ) ) { return false ; } } return true ; }
Checks if the fingerprint object was generated from an INVALID_UFS_FINGERPRINT .
12,361
public boolean matchMetadata ( Fingerprint fp ) { for ( Tag tag : METADATA_TAGS ) { if ( ! getTag ( tag ) . equals ( fp . getTag ( tag ) ) ) { return false ; } } return true ; }
Returns true if the serialized fingerprint matches the fingerprint in metadata .
12,362
public boolean matchContent ( Fingerprint fp ) { for ( Tag tag : CONTENT_TAGS ) { if ( ! getTag ( tag ) . equals ( fp . getTag ( tag ) ) ) { return false ; } } return true ; }
Returns true if the serialized fingerprint matches the fingerprint in the content part .
12,363
public void putTag ( Tag tag , String value ) { if ( value != null ) { mValues . put ( tag , sanitizeString ( value ) ) ; } }
Updates a specific tag in the fingerprint . If the new value is null the fingerprint is kept unchanged .
12,364
private void openStream ( ) throws IOException { if ( mIn != null ) { return ; } GetObjectRequest getReq = new GetObjectRequest ( mBucketName , mKey ) ; if ( mPos > 0 ) { getReq . setRange ( mPos ) ; } AmazonS3Exception lastException = null ; while ( mRetryPolicy . attempt ( ) ) { try { mIn = mClient . getObject ( getR...
Opens a new stream at mPos if the wrapped stream mIn is null .
12,365
public void removeChild ( DirectedAcyclicGraphNode < T > child ) { Preconditions . checkState ( mChildren . contains ( child ) ) ; mChildren . remove ( child ) ; }
Removes a child node from the node .
12,366
public void setEntry ( AclEntry entry ) { switch ( entry . getType ( ) ) { case NAMED_USER : case NAMED_GROUP : case MASK : if ( mExtendedEntries == null ) { mExtendedEntries = new ExtendedACLEntries ( ) ; } mExtendedEntries . setEntry ( entry ) ; return ; case OWNING_USER : Mode modeOwner = new Mode ( mMode ) ; modeOw...
Sets an entry into the access control list . If an entry with the same type and subject already exists overwrites the existing entry ; Otherwise adds this new entry . After we modify entries for NAMED_GROUP OWNING_GROUP NAMED_USER we need to update the mask .
12,367
public boolean checkPermission ( String user , List < String > groups , AclAction action ) { return getPermission ( user , groups ) . contains ( action ) ; }
Checks whether the user has the permission to perform the action .
12,368
public AclActions getPermission ( String user , List < String > groups ) { if ( user . equals ( mOwningUser ) ) { return new AclActions ( getOwningUserActions ( ) ) ; } if ( hasExtended ( ) ) { AclActions actions = mExtendedEntries . getNamedUser ( user ) ; if ( actions != null ) { AclActions result = new AclActions ( ...
Gets the permitted actions for a user .
12,369
public static AccessControlList fromStringEntries ( String owner , String owningGroup , List < String > stringEntries ) { AccessControlList acl ; if ( stringEntries . size ( ) > 0 ) { AclEntry aclEntry = AclEntry . fromCliString ( stringEntries . get ( 0 ) ) ; if ( aclEntry . isDefault ( ) ) { acl = new DefaultAccessCo...
Converts a list of string entries into an AccessControlList or a DefaultAccessControlList . It assumes the stringEntries contain all default entries or normal entries .
12,370
public < V > boolean contains ( IndexDefinition < T , V > indexDefinition , V value ) { FieldIndex < T , V > index = ( FieldIndex < T , V > ) mIndices . get ( indexDefinition ) ; if ( index == null ) { throw new IllegalStateException ( "the given index isn't defined for this IndexedSet" ) ; } return index . containsFie...
Whether there is an object with the specified index field value in the set .
12,371
public < V > Set < T > getByField ( IndexDefinition < T , V > indexDefinition , V value ) { FieldIndex < T , V > index = ( FieldIndex < T , V > ) mIndices . get ( indexDefinition ) ; if ( index == null ) { throw new IllegalStateException ( "the given index isn't defined for this IndexedSet" ) ; } return index . getByFi...
Gets a subset of objects with the specified field value . If there is no object with the specified field value a newly created empty set is returned .
12,372
public < V > T getFirstByField ( IndexDefinition < T , V > indexDefinition , V value ) { FieldIndex < T , V > index = ( FieldIndex < T , V > ) mIndices . get ( indexDefinition ) ; if ( index == null ) { throw new IllegalStateException ( "the given index isn't defined for this IndexedSet" ) ; } return index . getFirst (...
Gets the object from the set of objects with the specified field value .
12,373
public boolean remove ( Object object ) { if ( object == null ) { return false ; } synchronized ( object ) { if ( mPrimaryIndex . containsObject ( ( T ) object ) ) { @ SuppressWarnings ( "unchecked" ) T tObj = ( T ) object ; removeFromIndices ( tObj ) ; return true ; } else { return false ; } } }
Removes an object from the set .
12,374
private void removeFromIndices ( T object ) { for ( FieldIndex < T , ? > fieldValue : mIndices . values ( ) ) { fieldValue . remove ( object ) ; } }
Helper method that removes an object from the indices .
12,375
public < V > int removeByField ( IndexDefinition < T , V > indexDefinition , V value ) { Set < T > toRemove = getByField ( indexDefinition , value ) ; int removed = 0 ; for ( T o : toRemove ) { if ( remove ( o ) ) { removed ++ ; } } return removed ; }
Removes the subset of objects with the specified index field value .
12,376
public synchronized void updateConfigurationDefaults ( InetSocketAddress address ) throws AlluxioStatusException { Pair < AlluxioConfiguration , PathConfiguration > conf = ConfigurationUtils . loadClusterAndPathDefaults ( address , mConf , mPathConf ) ; mConf = conf . getFirst ( ) ; mPathConf = conf . getSecond ( ) ; }
This method will attempt to load the cluster and path level configuration defaults and update the configuration if necessary .
12,377
public synchronized int waitForAndKillPrimaryMaster ( int timeoutMs ) throws TimeoutException , InterruptedException { int index = getPrimaryMasterIndex ( timeoutMs ) ; mMasters . get ( index ) . close ( ) ; return index ; }
Kills the primary master .
12,378
public synchronized int getPrimaryMasterIndex ( int timeoutMs ) throws TimeoutException , InterruptedException { final FileSystem fs = getFileSystemClient ( ) ; final MasterInquireClient inquireClient = getMasterInquireClient ( ) ; CommonUtils . waitFor ( "a primary master to be serving" , ( ) -> { try { fs . getStatus...
Gets the index of the primary master .
12,379
public synchronized void waitForAllNodesRegistered ( int timeoutMs ) throws TimeoutException , InterruptedException { MetaMasterClient metaMasterClient = getMetaMasterClient ( ) ; CommonUtils . waitFor ( "all nodes registered" , ( ) -> { try { MasterInfo masterInfo = metaMasterClient . getMasterInfo ( Collections . emp...
Waits for all nodes to be registered .
12,380
public synchronized void saveWorkdir ( ) throws IOException { Preconditions . checkState ( mState == State . STARTED , "cluster must be started before you can save its work directory" ) ; ARTIFACTS_DIR . mkdirs ( ) ; File tarball = new File ( mWorkDir . getParentFile ( ) , mWorkDir . getName ( ) + ".tar.gz" ) ; Process...
Copies the work directory to the artifacts folder .
12,381
public synchronized void destroy ( ) throws IOException { if ( mState == State . DESTROYED ) { return ; } if ( ! mSuccess ) { saveWorkdir ( ) ; } mCloser . close ( ) ; LOG . info ( "Destroyed cluster {}" , mClusterName ) ; mState = State . DESTROYED ; }
Destroys the cluster . It may not be re - started after being destroyed .
12,382
public synchronized void startMaster ( int i ) throws IOException { Preconditions . checkState ( mState == State . STARTED , "Must be in a started state to start masters" ) ; mMasters . get ( i ) . start ( ) ; }
Starts the specified master .
12,383
public synchronized void startWorker ( int i ) throws IOException { Preconditions . checkState ( mState == State . STARTED , "Must be in a started state to start workers" ) ; mWorkers . get ( i ) . start ( ) ; }
Starts the specified worker .
12,384
public synchronized void updateDeployMode ( DeployMode mode ) { mDeployMode = mode ; if ( mDeployMode == DeployMode . EMBEDDED ) { for ( int i = 0 ; i < mMasters . size ( ) ; i ++ ) { Master master = mMasters . get ( i ) ; MasterNetAddress address = mMasterAddresses . get ( i ) ; master . updateConf ( PropertyKey . MAS...
Updates the cluster s deploy mode .
12,385
private synchronized Master createMaster ( int i ) throws IOException { Preconditions . checkState ( mState == State . STARTED , "Must be in a started state to create masters" ) ; MasterNetAddress address = mMasterAddresses . get ( i ) ; File confDir = new File ( mWorkDir , "conf-master" + i ) ; File metastoreDir = new...
Creates the specified master without starting it .
12,386
private synchronized Worker createWorker ( int i ) throws IOException { Preconditions . checkState ( mState == State . STARTED , "Must be in a started state to create workers" ) ; File confDir = new File ( mWorkDir , "conf-worker" + i ) ; File logsDir = new File ( mWorkDir , "logs-worker" + i ) ; File ramdisk = new Fil...
Creates the specified worker without starting it .
12,387
public synchronized void formatJournal ( ) throws IOException { if ( mDeployMode == DeployMode . EMBEDDED ) { for ( Master master : mMasters ) { File journalDir = new File ( master . getConf ( ) . get ( PropertyKey . MASTER_JOURNAL_FOLDER ) ) ; FileUtils . deleteDirectory ( journalDir ) ; journalDir . mkdirs ( ) ; } re...
Formats the cluster journal .
12,388
private void writeConf ( ) throws IOException { for ( int i = 0 ; i < mNumMasters ; i ++ ) { File confDir = new File ( mWorkDir , "conf-master" + i ) ; writeConfToFile ( confDir , mMasterProperties . getOrDefault ( i , new HashMap < > ( ) ) ) ; } for ( int i = 0 ; i < mNumWorkers ; i ++ ) { File confDir = new File ( mW...
Writes the contents of properties to the configuration file .
12,389
private void writeConfToFile ( File dir , Map < PropertyKey , String > properties ) throws IOException { Map < PropertyKey , String > map = new HashMap < > ( mProperties ) ; for ( Map . Entry < PropertyKey , String > entry : properties . entrySet ( ) ) { map . put ( entry . getKey ( ) , entry . getValue ( ) ) ; } Strin...
Creates the conf directory and file . Writes the properties to the generated file .
12,390
public CreateDirectoryContext setDefaultAcl ( List < AclEntry > defaultAcl ) { mDefaultAcl = ImmutableList . copyOf ( defaultAcl ) ; return getThis ( ) ; }
Sets the default ACL in the context .
12,391
protected void scheduleAsyncPersist ( ) throws IOException { try ( CloseableResource < FileSystemMasterClient > masterClient = mContext . acquireMasterClientResource ( ) ) { ScheduleAsyncPersistencePOptions persistOptions = FileSystemOptions . scheduleAsyncPersistDefaults ( mContext . getPathConf ( mUri ) ) . toBuilder...
Schedules the async persistence of the current file .
12,392
public static void printPassInfo ( boolean pass ) { if ( pass ) { System . out . println ( Constants . ANSI_GREEN + "Passed the test!" + Constants . ANSI_RESET ) ; } else { System . out . println ( Constants . ANSI_RED + "Failed the test!" + Constants . ANSI_RESET ) ; } }
Prints information of the test result .
12,393
public static boolean runExample ( final Callable < Boolean > example ) { boolean result ; try { result = example . call ( ) ; } catch ( Exception e ) { LOG . error ( "Exception running test: " + example , e ) ; result = false ; } CliUtils . printPassInfo ( result ) ; return result ; }
Runs an example .
12,394
public static AlluxioBlockStore create ( FileSystemContext context ) { return new AlluxioBlockStore ( context , TieredIdentityFactory . localIdentity ( context . getClusterConf ( ) ) ) ; }
Creates an Alluxio block store with default local hostname .
12,395
public BlockInfo getInfo ( long blockId ) throws IOException { try ( CloseableResource < BlockMasterClient > masterClientResource = mContext . acquireBlockMasterClientResource ( ) ) { return masterClientResource . get ( ) . getBlockInfo ( blockId ) ; } }
Gets the block info of a block if it exists .
12,396
public BlockInStream getInStream ( long blockId , InStreamOptions options ) throws IOException { return getInStream ( blockId , options , ImmutableMap . of ( ) ) ; }
Gets a stream to read the data of a block . This method is primarily responsible for determining the data source and type of data source . The latest BlockInfo will be fetched from the master to ensure the locations are up to date .
12,397
public BlockOutStream getOutStream ( long blockId , long blockSize , WorkerNetAddress address , OutStreamOptions options ) throws IOException { if ( blockSize == - 1 ) { try ( CloseableResource < BlockMasterClient > blockMasterClientResource = mContext . acquireBlockMasterClientResource ( ) ) { blockSize = blockMasterC...
Gets a stream to write data to a block . The stream can only be backed by Alluxio storage .
12,398
public BlockOutStream getOutStream ( long blockId , long blockSize , OutStreamOptions options ) throws IOException { WorkerNetAddress address ; BlockLocationPolicy locationPolicy = Preconditions . checkNotNull ( options . getLocationPolicy ( ) , PreconditionMessage . BLOCK_WRITE_LOCATION_POLICY_UNSPECIFIED ) ; GetWorke...
Gets a stream to write data to a block based on the options . The stream can only be backed by Alluxio storage .
12,399
public long getCapacityBytes ( ) throws IOException { try ( CloseableResource < BlockMasterClient > blockMasterClientResource = mContext . acquireBlockMasterClientResource ( ) ) { return blockMasterClientResource . get ( ) . getCapacityBytes ( ) ; } }
Gets the total capacity of Alluxio s BlockStore .