idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
12,700
private static boolean isValidAddress ( InetAddress address , int timeoutMs ) throws IOException { return ! address . isAnyLocalAddress ( ) && ! address . isLinkLocalAddress ( ) && ! address . isLoopbackAddress ( ) && address . isReachable ( timeoutMs ) && ( address instanceof Inet4Address ) ; }
Tests if the address is externally resolvable . Address must not be wildcard link local loopback address non - IPv4 or other unreachable addresses .
12,701
public static String resolveIpAddress ( String hostname ) throws UnknownHostException { Preconditions . checkNotNull ( hostname , "hostname" ) ; Preconditions . checkArgument ( ! hostname . isEmpty ( ) , "Cannot resolve IP address for empty hostname" ) ; return InetAddress . getByName ( hostname ) . getHostAddress ( ) ...
Resolves a given hostname IP address .
12,702
public static InetSocketAddress getRpcPortSocketAddress ( WorkerNetAddress netAddress ) { String host = netAddress . getHost ( ) ; int port = netAddress . getRpcPort ( ) ; return new InetSocketAddress ( host , port ) ; }
Extracts rpcPort InetSocketAddress from Alluxio representation of network address .
12,703
public static SocketAddress getDataPortSocketAddress ( WorkerNetAddress netAddress , AlluxioConfiguration conf ) { SocketAddress address ; if ( NettyUtils . isDomainSocketSupported ( netAddress , conf ) ) { address = new DomainSocketAddress ( netAddress . getDomainSocketPath ( ) ) ; } else { String host = netAddress . ...
Extracts dataPort socket address from Alluxio representation of network address .
12,704
public static void pingService ( InetSocketAddress address , alluxio . grpc . ServiceType serviceType , AlluxioConfiguration conf ) throws AlluxioStatusException { Preconditions . checkNotNull ( address , "address" ) ; Preconditions . checkNotNull ( serviceType , "serviceType" ) ; GrpcChannel channel = GrpcChannelBuild...
Test if the input address is serving an Alluxio service . This method make use of the gRPC protocol for performing service communication .
12,705
public synchronized void regenerateReport ( ) { Map < PropertyKey , Map < Optional < String > , List < String > > > confMap = generateConfMap ( ) ; Map < Scope , List < InconsistentProperty > > confErrors = new HashMap < > ( ) ; Map < Scope , List < InconsistentProperty > > confWarns = new HashMap < > ( ) ; for ( Map ....
Checks the server - side configurations and records the check results .
12,706
public synchronized void logConfigReport ( ) { ConfigStatus reportStatus = mConfigCheckReport . getConfigStatus ( ) ; if ( reportStatus . equals ( ConfigStatus . PASSED ) ) { LOG . info ( CONSISTENT_CONFIGURATION_INFO ) ; } else if ( reportStatus . equals ( ConfigStatus . WARN ) ) { LOG . warn ( "{}\nWarnings: {}" , IN...
Logs the configuration check report information .
12,707
private void fillConfMap ( Map < PropertyKey , Map < Optional < String > , List < String > > > targetMap , Map < Address , List < ConfigRecord > > recordMap ) { for ( Map . Entry < Address , List < ConfigRecord > > record : recordMap . entrySet ( ) ) { Address address = record . getKey ( ) ; String addressStr = String ...
Fills the configuration map .
12,708
private void updateStream ( ) throws IOException { if ( mBlockInStream != null && mBlockInStream . remaining ( ) > 0 ) { return ; } if ( mBlockInStream != null && mBlockInStream . remaining ( ) == 0 ) { closeBlockInStream ( mBlockInStream ) ; } long blockId = mStatus . getBlockIds ( ) . get ( Math . toIntExact ( mPosit...
Initializes the underlying block stream if necessary . This method must be called before reading from mBlockInStream .
12,709
private void triggerAsyncCaching ( BlockInStream stream ) throws IOException { boolean cache = ReadType . fromProto ( mOptions . getOptions ( ) . getReadType ( ) ) . isCache ( ) ; boolean overReplicated = mStatus . getReplicationMax ( ) > 0 && mStatus . getFileBlockInfos ( ) . get ( ( int ) ( getPos ( ) / mBlockSize ) ...
Send an async cache request to a worker based on read type and passive cache options .
12,710
private long getTimeToNextBackup ( ) { LocalDateTime now = LocalDateTime . now ( Clock . systemUTC ( ) ) ; DateTimeFormatter formatter = DateTimeFormatter . ofPattern ( "H:mm" ) ; LocalTime backupTime = LocalTime . parse ( ServerConfiguration . get ( PropertyKey . MASTER_DAILY_BACKUP_TIME ) , formatter ) ; LocalDateTim...
Gets the time gap between now and next backup time .
12,711
private void dailyBackup ( ) { try { BackupResponse resp = mMetaMaster . backup ( BackupPOptions . newBuilder ( ) . setTargetDirectory ( mBackupDir ) . setLocalFileSystem ( mIsLocal ) . build ( ) ) ; if ( mIsLocal ) { LOG . info ( "Successfully backed up journal to {} on master {}" , resp . getBackupUri ( ) , resp . ge...
The daily backup task .
12,712
private void deleteStaleBackups ( ) throws Exception { UfsStatus [ ] statuses = mUfs . listStatus ( mBackupDir ) ; if ( statuses . length <= mRetainedFiles ) { return ; } TreeMap < Instant , String > timeToFile = new TreeMap < > ( ( a , b ) -> ( a . isBefore ( b ) ? - 1 : a . isAfter ( b ) ? 1 : 0 ) ) ; for ( UfsStatus...
Deletes stale backup files to avoid consuming too many spaces .
12,713
public void submitRequest ( AsyncCacheRequest request ) { ASYNC_CACHE_REQUESTS . inc ( ) ; long blockId = request . getBlockId ( ) ; long blockLength = request . getLength ( ) ; if ( mPendingRequests . putIfAbsent ( blockId , request ) != null ) { ASYNC_CACHE_DUPLICATE_REQUESTS . inc ( ) ; return ; } try { mAsyncCacheE...
Handles a request to cache a block asynchronously . This is a non - blocking call .
12,714
private boolean cacheBlockFromUfs ( long blockId , long blockSize , Protocol . OpenUfsBlockOptions openUfsBlockOptions ) { try { if ( ! mBlockWorker . openUfsBlock ( Sessions . ASYNC_CACHE_SESSION_ID , blockId , openUfsBlockOptions ) ) { LOG . warn ( "Failed to async cache block {} from UFS on opening the block" , bloc...
Caches the block via the local worker to read from UFS .
12,715
public void flush ( final long targetCounter ) throws IOException , JournalClosedException { if ( targetCounter <= mFlushCounter . get ( ) ) { return ; } FlushTicket ticket = new FlushTicket ( targetCounter ) ; try ( LockResource lr = new LockResource ( mTicketLock ) ) { mTicketList . add ( ticket ) ; } try { mFlushSem...
Submits a ticket to flush thread and waits until ticket is served .
12,716
public void updateFromEntry ( UpdateInodeFileEntry entry ) { if ( entry . hasPersistJobId ( ) ) { setPersistJobId ( entry . getPersistJobId ( ) ) ; } if ( entry . hasReplicationMax ( ) ) { setReplicationMax ( entry . getReplicationMax ( ) ) ; } if ( entry . hasReplicationMin ( ) ) { setReplicationMin ( entry . getRepli...
Updates this inode file s state from the given entry .
12,717
public static byte [ ] serialize ( Object obj ) throws IOException { if ( obj == null ) { return null ; } try ( ByteArrayOutputStream b = new ByteArrayOutputStream ( ) ) { try ( ObjectOutputStream o = new ObjectOutputStream ( b ) ) { o . writeObject ( obj ) ; } return b . toByteArray ( ) ; } }
Serializes an object into a byte array . When the object is null returns null .
12,718
public static Serializable deserialize ( byte [ ] bytes ) throws IOException , ClassNotFoundException { if ( bytes == null ) { return null ; } try ( ByteArrayInputStream b = new ByteArrayInputStream ( bytes ) ) { try ( ObjectInputStream o = new ObjectInputStream ( b ) ) { return ( Serializable ) o . readObject ( ) ; } ...
Deserializes a byte array into an object . When the bytes are null returns null .
12,719
private List < Map . Entry < Long , Double > > getSortedCRF ( ) { List < Map . Entry < Long , Double > > sortedCRF = new ArrayList < > ( mBlockIdToCRFValue . entrySet ( ) ) ; sortedCRF . sort ( Comparator . comparingDouble ( Entry :: getValue ) ) ; return sortedCRF ; }
Sorts all blocks in ascending order of CRF .
12,720
public static File [ ] listExtensions ( String extensionDir ) { File [ ] extensions = new File ( extensionDir ) . listFiles ( file -> file . getPath ( ) . toLowerCase ( ) . endsWith ( Constants . EXTENSION_JAR ) ) ; if ( extensions == null ) { return EMPTY_EXTENSIONS_LIST ; } return extensions ; }
List extension jars from the configured extensions directory .
12,721
public boolean belongsTo ( BlockStoreLocation location ) { boolean tierInRange = tierAlias ( ) . equals ( location . tierAlias ( ) ) || location . tierAlias ( ) . equals ( ANY_TIER ) ; boolean dirInRange = ( dir ( ) == location . dir ( ) ) || ( location . dir ( ) == ANY_DIR ) ; return tierInRange && dirInRange ; }
Returns whether this location belongs to the specific location .
12,722
public void stop ( ) throws Exception { for ( Connector connector : mServer . getConnectors ( ) ) { connector . stop ( ) ; } mServer . stop ( ) ; }
Shuts down the web server .
12,723
public void start ( ) { try { mServer . start ( ) ; LOG . info ( "{} started @ {}" , mServiceName , mAddress ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
Starts the web server .
12,724
static final void eraseThreadLocals ( Thread thread ) { U . putObject ( thread , THREADLOCALS , null ) ; U . putObject ( thread , INHERITABLETHREADLOCALS , null ) ; }
Erases ThreadLocals by nulling out Thread maps .
12,725
public void awaitTermination ( boolean waitQuietPeriod ) { LOG . info ( "{}: Journal checkpointer shutdown has been initiated." , mMaster . getName ( ) ) ; mWaitQuietPeriod = waitQuietPeriod ; mShutdownInitiated = true ; synchronized ( mCheckpointingLock ) { if ( mCheckpointing ) { interrupt ( ) ; } } try { join ( ) ; ...
Initiates the shutdown of this checkpointer thread and also waits for it to finish .
12,726
private void maybeCheckpoint ( ) { if ( mShutdownInitiated ) { return ; } long nextSequenceNumber = mJournalReader . getNextSequenceNumber ( ) ; if ( nextSequenceNumber - mNextSequenceNumberToCheckpoint < mCheckpointPeriodEntries ) { return ; } try { mNextSequenceNumberToCheckpoint = mJournal . getNextSequenceNumberToC...
Creates a new checkpoint if necessary .
12,727
public void addTempBlockMeta ( TempBlockMeta tempBlockMeta ) throws WorkerOutOfSpaceException , BlockAlreadyExistsException { StorageDir dir = tempBlockMeta . getParentDir ( ) ; dir . addTempBlockMeta ( tempBlockMeta ) ; }
Adds a temp block .
12,728
public void cleanupSessionTempBlocks ( long sessionId , List < Long > tempBlockIds ) { for ( StorageTier tier : mTiers ) { for ( StorageDir dir : tier . getStorageDirs ( ) ) { dir . cleanupSessionTempBlocks ( sessionId , tempBlockIds ) ; } } }
Cleans up the metadata of the given temp block ids .
12,729
public BlockMeta getBlockMeta ( long blockId ) throws BlockDoesNotExistException { for ( StorageTier tier : mTiers ) { for ( StorageDir dir : tier . getStorageDirs ( ) ) { if ( dir . hasBlockMeta ( blockId ) ) { return dir . getBlockMeta ( blockId ) ; } } } throw new BlockDoesNotExistException ( ExceptionMessage . BLOC...
Gets the metadata of a block given its block id .
12,730
public List < TempBlockMeta > getSessionTempBlocks ( long sessionId ) { List < TempBlockMeta > sessionTempBlocks = new ArrayList < > ( ) ; for ( StorageTier tier : mTiers ) { for ( StorageDir dir : tier . getStorageDirs ( ) ) { sessionTempBlocks . addAll ( dir . getSessionTempBlocks ( sessionId ) ) ; } } return session...
Gets all the temporary blocks associated with a session empty list is returned if the session has no temporary blocks .
12,731
public boolean hasBlockMeta ( long blockId ) { for ( StorageTier tier : mTiers ) { for ( StorageDir dir : tier . getStorageDirs ( ) ) { if ( dir . hasBlockMeta ( blockId ) ) { return true ; } } } return false ; }
Checks if the storage has a given block .
12,732
public BlockMeta moveBlockMeta ( BlockMeta blockMeta , TempBlockMeta tempBlockMeta ) throws BlockDoesNotExistException , WorkerOutOfSpaceException , BlockAlreadyExistsException { StorageDir srcDir = blockMeta . getParentDir ( ) ; StorageDir dstDir = tempBlockMeta . getParentDir ( ) ; srcDir . removeBlockMeta ( blockMet...
Moves an existing block to another location currently hold by a temp block .
12,733
public void removeBlockMeta ( BlockMeta block ) throws BlockDoesNotExistException { StorageDir dir = block . getParentDir ( ) ; dir . removeBlockMeta ( block ) ; }
Removes the metadata of a specific block .
12,734
public void resizeTempBlockMeta ( TempBlockMeta tempBlockMeta , long newSize ) throws InvalidWorkerStateException { StorageDir dir = tempBlockMeta . getParentDir ( ) ; dir . resizeTempBlockMeta ( tempBlockMeta , newSize ) ; }
Modifies the size of a temp block .
12,735
public void start ( String channelId ) throws AlluxioStatusException { try { LOG . debug ( "Starting SASL handshake for ChannelId:{}" , channelId ) ; mRequestObserver . onNext ( mSaslHandshakeClientHandler . getInitialMessage ( channelId ) ) ; mAuthenticated . get ( mGrpcAuthTimeoutMs , TimeUnit . MILLISECONDS ) ; } ca...
Starts authentication with the server and wait until completion .
12,736
public static String [ ] convertToNames ( UfsStatus [ ] children ) { if ( children == null ) { return null ; } String [ ] ret = new String [ children . length ] ; for ( int i = 0 ; i < children . length ; ++ i ) { ret [ i ] = children [ i ] . getName ( ) ; } return ret ; }
Converts an array of UFS file status to a listing result where each element in the array is a file or directory name .
12,737
public static void createMasters ( MasterRegistry registry , MasterContext context ) { List < Callable < Void > > callables = new ArrayList < > ( ) ; for ( final MasterFactory factory : alluxio . master . ServiceUtils . getMasterServiceLoader ( ) ) { callables . add ( ( ) -> { if ( factory . isEnabled ( ) ) { factory ....
Creates all the masters and registers them to the master registry .
12,738
public static StorageDirView selectDirWithRequestedSpace ( long bytesToBeAvailable , BlockStoreLocation location , BlockMetadataManagerView mManagerView ) { if ( location . equals ( BlockStoreLocation . anyTier ( ) ) ) { for ( StorageTierView tierView : mManagerView . getTierViews ( ) ) { for ( StorageDirView dirView :...
Finds a directory in the given location range with capacity upwards of the given bound .
12,739
public void onNext ( OpenLocalBlockRequest request ) { RpcUtils . streamingRPCAndLog ( LOG , new RpcUtils . StreamingRpcCallable < OpenLocalBlockResponse > ( ) { public OpenLocalBlockResponse call ( ) throws Exception { Preconditions . checkState ( mRequest == null ) ; mRequest = request ; if ( mLockId == BlockLockMana...
Handles block open request .
12,740
public void onCompleted ( ) { RpcUtils . streamingRPCAndLog ( LOG , new RpcUtils . StreamingRpcCallable < OpenLocalBlockResponse > ( ) { public OpenLocalBlockResponse call ( ) throws Exception { if ( mLockId != BlockLockManager . INVALID_LOCK_ID ) { mWorker . unlockBlock ( mLockId ) ; mLockId = BlockLockManager . INVAL...
Handles block close request . No exceptions should be thrown .
12,741
public void run ( ) { Protos . FrameworkInfo . Builder frameworkInfo = Protos . FrameworkInfo . newBuilder ( ) . setName ( "alluxio" ) . setCheckpoint ( true ) ; if ( ServerConfiguration . isSet ( PropertyKey . INTEGRATION_MESOS_ROLE ) ) { frameworkInfo . setRole ( ServerConfiguration . get ( PropertyKey . INTEGRATION_...
Runs the mesos framework .
12,742
private static String createMasterWebUrl ( ) { InetSocketAddress masterWeb = NetworkAddressUtils . getConnectAddress ( ServiceType . MASTER_WEB , ServerConfiguration . global ( ) ) ; return "http://" + masterWeb . getHostString ( ) + ":" + masterWeb . getPort ( ) ; }
Create AlluxioMaster web url .
12,743
public static void main ( String [ ] args ) throws Exception { AlluxioFramework framework = new AlluxioFramework ( ) ; JCommander jc = new JCommander ( framework ) ; try { jc . parse ( args ) ; } catch ( Exception e ) { System . out . println ( e . getMessage ( ) ) ; jc . usage ( ) ; System . exit ( 1 ) ; } framework ....
Starts the Alluxio framework .
12,744
static TieredIdentity create ( AlluxioConfiguration conf ) { TieredIdentity scriptIdentity = fromScript ( conf ) ; List < LocalityTier > tiers = new ArrayList < > ( ) ; List < String > orderedTierNames = conf . getList ( PropertyKey . LOCALITY_ORDER , "," ) ; for ( int i = 0 ; i < orderedTierNames . size ( ) ; i ++ ) {...
Creates a tiered identity based on configuration .
12,745
public UnderFileSystemConfiguration createMountSpecificConf ( Map < String , String > mountConf ) { UnderFileSystemConfiguration ufsConf = new UnderFileSystemConfiguration ( mProperties . copy ( ) ) ; ufsConf . mProperties . merge ( mountConf , Source . MOUNT_OPTION ) ; ufsConf . mReadOnly = mReadOnly ; ufsConf . mShar...
Creates a new instance from the current configuration and adds in new properties .
12,746
private void registerWithMaster ( ) throws IOException { BlockStoreMeta storeMeta = mBlockWorker . getStoreMetaFull ( ) ; StorageTierAssoc storageTierAssoc = new WorkerStorageTierAssoc ( ) ; List < ConfigProperty > configList = ConfigurationUtils . getConfiguration ( ServerConfiguration . global ( ) , Scope . WORKER ) ...
Registers with the Alluxio master . This should be called before the continuous heartbeat thread begins .
12,747
public void heartbeat ( ) { BlockHeartbeatReport blockReport = mBlockWorker . getReport ( ) ; BlockStoreMeta storeMeta = mBlockWorker . getStoreMeta ( ) ; Command cmdFromMaster = null ; List < alluxio . grpc . Metric > metrics = new ArrayList < > ( ) ; for ( Metric metric : MetricsSystem . allWorkerMetrics ( ) ) { metr...
Heartbeats to the master node about the change in the worker s managed space .
12,748
private void applyEntry ( JournalEntry entry ) { Preconditions . checkState ( entry . getAllFields ( ) . size ( ) <= 1 || ( entry . getAllFields ( ) . size ( ) == 2 && entry . hasSequenceNumber ( ) ) , "Raft journal entries should never set multiple fields in addition to sequence " + "number, but found %s" , entry ) ; ...
Applies the journal entry ignoring empty entries and expanding multi - entries .
12,749
public static List < UnderFileSystemFactory > findAll ( String path , UnderFileSystemConfiguration ufsConf , AlluxioConfiguration alluxioConf ) { List < UnderFileSystemFactory > eligibleFactories = sRegistryInstance . findAll ( path , ufsConf , alluxioConf ) ; if ( eligibleFactories . isEmpty ( ) && ufsConf != null ) {...
Finds all the Under File System factories that support the given path .
12,750
private void load ( AlluxioURI filePath , int replication ) throws AlluxioException , IOException , InterruptedException { URIStatus status = mFileSystem . getStatus ( filePath ) ; if ( status . isFolder ( ) ) { List < URIStatus > statuses = mFileSystem . listStatus ( filePath ) ; for ( URIStatus uriStatus : statuses )...
Loads a file or directory in Alluxio space makes it resident in memory .
12,751
private UnderFileSystem getOrAdd ( AlluxioURI ufsUri , UnderFileSystemConfiguration ufsConf ) { Key key = new Key ( ufsUri , ufsConf . getMountSpecificConf ( ) ) ; UnderFileSystem cachedFs = mUnderFileSystemMap . get ( key ) ; if ( cachedFs != null ) { return cachedFs ; } synchronized ( mLock ) { cachedFs = mUnderFileS...
Return a UFS instance if it already exists in the cache otherwise creates a new instance and return this .
12,752
private static List < AlluxioURI > getAlluxioURIs ( FileSystem alluxioClient , AlluxioURI inputURI , AlluxioURI parentDir ) throws IOException { List < AlluxioURI > res = new ArrayList < > ( ) ; List < URIStatus > statuses ; try { statuses = alluxioClient . listStatus ( parentDir ) ; } catch ( AlluxioException e ) { th...
The utility function used to implement getAlluxioURIs .
12,753
private static List < File > getFiles ( String inputPath , String parent ) { List < File > res = new ArrayList < > ( ) ; File pFile = new File ( parent ) ; if ( ! pFile . exists ( ) || ! pFile . isDirectory ( ) ) { return res ; } if ( pFile . isDirectory ( ) && pFile . canRead ( ) ) { File [ ] fileList = pFile . listFi...
The utility function used to implement getFiles .
12,754
public static int getIntArg ( CommandLine cl , Option option , int defaultValue ) { int arg = defaultValue ; if ( cl . hasOption ( option . getLongOpt ( ) ) ) { String argOption = cl . getOptionValue ( option . getLongOpt ( ) ) ; arg = Integer . parseInt ( argOption ) ; } return arg ; }
Gets the value of an option from the command line .
12,755
public static long getMs ( String time ) { try { return FormatUtils . parseTimeSize ( time ) ; } catch ( Exception e ) { throw new RuntimeException ( ExceptionMessage . INVALID_TIME . getMessage ( time ) ) ; } }
Converts the input time into millisecond unit .
12,756
private static boolean match ( AlluxioURI fileURI , AlluxioURI patternURI ) { return escape ( fileURI . getPath ( ) ) . matches ( replaceWildcards ( patternURI . getPath ( ) ) ) ; }
Returns whether or not fileURI matches the patternURI .
12,757
public static boolean match ( String filePath , String patternPath ) { return match ( new AlluxioURI ( filePath ) , new AlluxioURI ( patternPath ) ) ; }
Returns whether or not filePath matches patternPath .
12,758
public synchronized void setUfsMode ( Supplier < JournalContext > journalContext , AlluxioURI ufsPath , UfsMode ufsMode ) throws InvalidPathException { LOG . info ( "Set ufs mode for {} to {}" , ufsPath , ufsMode ) ; String root = ufsPath . getRootPath ( ) ; if ( ! mUfsRoots . contains ( root ) ) { LOG . warn ( "No man...
Set the operation mode the given physical ufs .
12,759
public final CountedCompleter < ? > getRoot ( ) { CountedCompleter < ? > a = this , p ; while ( ( p = a . completer ) != null ) a = p ; return a ; }
Returns the root of the current computation ; i . e . this task if it has no completer else its completer s root .
12,760
public final void helpComplete ( int maxTasks ) { Thread t ; ForkJoinWorkerThread wt ; if ( maxTasks > 0 && status >= 0 ) { if ( ( t = Thread . currentThread ( ) ) instanceof ForkJoinWorkerThread ) ( wt = ( ForkJoinWorkerThread ) t ) . pool . helpComplete ( wt . workQueue , this , maxTasks ) ; else ForkJoinPool . commo...
If this task has not completed attempts to process at most the given number of other unprocessed tasks for which this task is on the completion path if any are known to exist .
12,761
void internalPropagateException ( Throwable ex ) { CountedCompleter < ? > a = this , s = a ; while ( a . onExceptionalCompletion ( ex , s ) && ( a = ( s = a ) . completer ) != null && a . status >= 0 && a . recordExceptionalCompletion ( ex ) == EXCEPTIONAL ) ; }
Supports ForkJoinTask exception propagation .
12,762
public static PStatus toProto ( Status status ) { switch ( status . getCode ( ) ) { case ABORTED : return PStatus . ABORTED ; case ALREADY_EXISTS : return PStatus . ALREADY_EXISTS ; case CANCELLED : return PStatus . CANCELED ; case DATA_LOSS : return PStatus . DATA_LOSS ; case DEADLINE_EXCEEDED : return PStatus . DEADL...
Converts an internal exception status to a protocol buffer type status .
12,763
public static SetAclAction fromProto ( File . PSetAclAction pSetAclAction ) { if ( pSetAclAction == null ) { throw new IllegalStateException ( "Null proto set acl action." ) ; } switch ( pSetAclAction ) { case REPLACE : return SetAclAction . REPLACE ; case MODIFY : return SetAclAction . MODIFY ; case REMOVE : return Se...
Converts proto type to wire type .
12,764
public int run ( ) throws IOException { ConfigCheckReport report = mMetaMasterClient . getConfigReport ( ) ; ConfigStatus configStatus = report . getConfigStatus ( ) ; if ( configStatus == ConfigStatus . PASSED ) { mPrintStream . println ( "No server-side configuration errors or warnings." ) ; return 0 ; } Map < Scope ...
Runs doctor configuration command .
12,765
private void printInconsistentProperties ( Map < Scope , List < InconsistentProperty > > inconsistentProperties ) { for ( List < InconsistentProperty > list : inconsistentProperties . values ( ) ) { for ( InconsistentProperty prop : list ) { mPrintStream . println ( "key: " + prop . getName ( ) ) ; for ( Map . Entry < ...
Prints the inconsistent properties in server - side configuration .
12,766
private void startProxy ( ) throws Exception { mProxyProcess = ProxyProcess . Factory . create ( ) ; Runnable runProxy = ( ) -> { try { mProxyProcess . start ( ) ; } catch ( InterruptedException e ) { } catch ( Exception e ) { LOG . error ( "Start proxy error" , e ) ; throw new RuntimeException ( e + " \n Start Proxy E...
Configures and starts the proxy .
12,767
public void formatAndRestartMasters ( ) throws Exception { stopMasters ( ) ; Format . format ( Format . Mode . MASTER , ServerConfiguration . global ( ) ) ; startMasters ( ) ; }
Stops the masters formats them and then restarts them . This is useful if a fresh state is desired for example when restoring from a backup .
12,768
protected void stopProxy ( ) throws Exception { mProxyProcess . stop ( ) ; if ( mProxyThread != null ) { while ( mProxyThread . isAlive ( ) ) { LOG . info ( "Stopping thread {}." , mProxyThread . getName ( ) ) ; mProxyThread . interrupt ( ) ; mProxyThread . join ( 1000 ) ; } mProxyThread = null ; } }
Stops the proxy .
12,769
public void stopWorkers ( ) throws Exception { if ( mWorkers == null ) { return ; } for ( WorkerProcess worker : mWorkers ) { worker . stop ( ) ; } for ( Thread thread : mWorkerThreads ) { while ( thread . isAlive ( ) ) { LOG . info ( "Stopping thread {}." , thread . getName ( ) ) ; thread . interrupt ( ) ; thread . jo...
Stops the workers .
12,770
public void waitForWorkersRegistered ( int timeoutMs ) throws TimeoutException , InterruptedException , IOException { try ( MetaMasterClient client = new RetryHandlingMetaMasterClient ( MasterClientContext . newBuilder ( ClientContext . create ( ServerConfiguration . global ( ) ) ) . build ( ) ) ) { CommonUtils . waitF...
Waits for all workers registered with master .
12,771
public static LocalAlluxioMaster create ( boolean includeSecondary ) throws IOException { String workDirectory = uniquePath ( ) ; FileUtils . deletePathRecursively ( workDirectory ) ; ServerConfiguration . set ( PropertyKey . WORK_DIR , workDirectory ) ; return create ( workDirectory , includeSecondary ) ; }
Creates a new local Alluxio master with an isolated work directory and port .
12,772
public static LocalAlluxioMaster create ( String workDirectory , boolean includeSecondary ) throws IOException { if ( ! Files . isDirectory ( Paths . get ( workDirectory ) ) ) { Files . createDirectory ( Paths . get ( workDirectory ) ) ; } return new LocalAlluxioMaster ( includeSecondary ) ; }
Creates a new local Alluxio master with a isolated port .
12,773
public void start ( ) { mMasterProcess = AlluxioMasterProcess . Factory . create ( ) ; Runnable runMaster = new Runnable ( ) { public void run ( ) { try { LOG . info ( "Starting Alluxio master {}." , mMasterProcess ) ; mMasterProcess . start ( ) ; } catch ( InterruptedException e ) { } catch ( Exception e ) { LOG . err...
Starts the master .
12,774
public void stop ( ) throws Exception { if ( mSecondaryMasterThread != null ) { mSecondaryMaster . stop ( ) ; while ( mSecondaryMasterThread . isAlive ( ) ) { LOG . info ( "Stopping thread {}." , mSecondaryMasterThread . getName ( ) ) ; mSecondaryMasterThread . join ( 1000 ) ; } mSecondaryMasterThread = null ; } if ( m...
Stops the master processes and cleans up client connections .
12,775
private synchronized void init ( MasterInquireClient masterInquireClient ) { mMasterInquireClient = masterInquireClient ; mFileSystemMasterClientPool = new FileSystemMasterClientPool ( mClientContext , mMasterInquireClient ) ; mBlockMasterClientPool = new BlockMasterClientPool ( mClientContext , mMasterInquireClient ) ...
Initializes the context . Only called in the factory methods .
12,776
public void releaseBlockWorkerClient ( WorkerNetAddress workerNetAddress , BlockWorkerClient client ) { SocketAddress address = NetworkAddressUtils . getDataPortSocketAddress ( workerNetAddress , getClusterConf ( ) ) ; ClientPoolKey key = new ClientPoolKey ( address , AuthenticationUserUtils . getImpersonationUser ( mC...
Releases a block worker client to the client pools .
12,777
private Journal . JournalEntry readInternal ( ) throws IOException { if ( mInputStream == null ) { return null ; } JournalEntry entry = mInputStream . mReader . readEntry ( ) ; if ( entry != null ) { return entry ; } if ( mInputStream . mFile . isIncompleteLog ( ) ) { return null ; } else { Preconditions . checkState (...
Reads the next journal entry .
12,778
private void updateInputStream ( ) throws IOException { if ( mInputStream != null && ( mInputStream . mFile . isIncompleteLog ( ) || ! mInputStream . isDone ( ) ) ) { return ; } if ( mInputStream != null ) { mInputStream . close ( ) ; mInputStream = null ; } if ( mFilesToProcess . isEmpty ( ) ) { UfsJournalSnapshot sna...
Updates the journal input stream by closing the current journal input stream if it is done and opening a new one .
12,779
private void printMetaMasterInfo ( ) throws IOException { mIndentationLevel ++ ; Set < MasterInfoField > masterInfoFilter = new HashSet < > ( Arrays . asList ( MasterInfoField . LEADER_MASTER_ADDRESS , MasterInfoField . WEB_PORT , MasterInfoField . RPC_PORT , MasterInfoField . START_TIME_MS , MasterInfoField . UP_TIME_...
Prints Alluxio meta master information .
12,780
private void printBlockMasterInfo ( ) throws IOException { Set < BlockMasterInfoField > blockMasterInfoFilter = new HashSet < > ( Arrays . asList ( BlockMasterInfoField . LIVE_WORKER_NUM , BlockMasterInfoField . LOST_WORKER_NUM , BlockMasterInfoField . CAPACITY_BYTES , BlockMasterInfoField . USED_BYTES , BlockMasterInf...
Prints Alluxio block master information .
12,781
public long getId ( final Address address ) throws IOException { return retryRPC ( ( ) -> mClient . getMasterId ( GetMasterIdPRequest . newBuilder ( ) . setMasterAddress ( address . toProto ( ) ) . build ( ) ) . getMasterId ( ) ) ; }
Returns a master id for a master address .
12,782
public MetaCommand heartbeat ( final long masterId ) throws IOException { return retryRPC ( ( ) -> mClient . masterHeartbeat ( MasterHeartbeatPRequest . newBuilder ( ) . setMasterId ( masterId ) . build ( ) ) . getCommand ( ) ) ; }
Sends a heartbeat to the leader master . Standby masters periodically execute this method so that the leader master knows they are still running .
12,783
public void register ( final long masterId , final List < ConfigProperty > configList ) throws IOException { retryRPC ( ( ) -> { mClient . registerMaster ( RegisterMasterPRequest . newBuilder ( ) . setMasterId ( masterId ) . setOptions ( RegisterMasterPOptions . newBuilder ( ) . addAllConfigs ( configList ) . build ( )...
Registers with the leader master .
12,784
public List < String > getGroups ( String user ) throws IOException { List < String > groups = CommonUtils . getUnixGroups ( user ) ; return new ArrayList < > ( new LinkedHashSet < > ( groups ) ) ; }
Returns list of groups for a user .
12,785
@ Path ( WEBUI_OVERVIEW ) @ ReturnType ( "alluxio.wire.WorkerWebUIOverview" ) public Response getWebUIOverview ( ) { return RestUtils . call ( ( ) -> { WorkerWebUIOverview response = new WorkerWebUIOverview ( ) ; response . setWorkerInfo ( new UIWorkerInfo ( mWorkerProcess . getRpcAddress ( ) . toString ( ) , mWorkerPr...
Gets web ui overview page data .
12,786
@ Path ( WEBUI_METRICS ) @ ReturnType ( "alluxio.wire.WorkerWebUIMetrics" ) public Response getWebUIMetrics ( ) { return RestUtils . call ( ( ) -> { WorkerWebUIMetrics response = new WorkerWebUIMetrics ( ) ; MetricRegistry mr = MetricsSystem . METRIC_REGISTRY ; Long workerCapacityTotal = ( Long ) mr . getGauges ( ) . g...
Gets web ui metrics page data .
12,787
private int getSkipCorrectedReference ( List < Integer > tokenPositions , int refNumber ) { int correctedRef = 0 ; int i = 0 ; for ( int tokenPosition : tokenPositions ) { if ( i ++ >= refNumber ) { break ; } correctedRef += tokenPosition ; } return correctedRef - 1 ; }
when there s a skip we need to adapt the reference number
12,788
public int compareTo ( RuleMatch other ) { Objects . requireNonNull ( other ) ; return Integer . compare ( getFromPos ( ) , other . getFromPos ( ) ) ; }
Compare by start position .
12,789
private boolean matchPostagRegexp ( AnalyzedTokenReadings aToken , Pattern pattern ) { for ( AnalyzedToken analyzedToken : aToken ) { String posTag = analyzedToken . getPOSTag ( ) ; if ( posTag == null ) { posTag = "UNKNOWN" ; } final Matcher m = pattern . matcher ( posTag ) ; if ( m . matches ( ) ) { return true ; } }...
Match POS tag with regular expression
12,790
public static Language getLanguageForName ( String languageName ) { for ( Language element : getStaticAndDynamicLanguages ( ) ) { if ( languageName . equals ( element . getName ( ) ) ) { return element ; } } return null ; }
Get the Language object for the given language name .
12,791
public static Language getLanguageForShortCode ( String langCode , List < String > noopLanguageCodes ) { Language language = getLanguageForShortCodeOrNull ( langCode ) ; if ( language == null ) { if ( noopLanguageCodes . contains ( langCode ) ) { return NOOP_LANGUAGE ; } else { List < String > codes = new ArrayList < >...
Get the Language object for the given language code .
12,792
protected final boolean isSatisfied ( AnalyzedToken aToken , Map < String , List < String > > uFeatures ) { if ( allFeatsIn && equivalencesMatched . isEmpty ( ) ) { return false ; } if ( uFeatures == null ) { throw new RuntimeException ( "isSatisfied called without features being set" ) ; } unificationFeats = uFeatures...
Tests if a token has shared features with other tokens .
12,793
public final void startUnify ( ) { allFeatsIn = true ; for ( int i = 0 ; i < tokCnt ; i ++ ) { featuresFound . add ( false ) ; } tmpFeaturesFound = new ArrayList < > ( featuresFound ) ; }
Starts testing only those equivalences that were previously matched .
12,794
public final boolean getFinalUnificationValue ( Map < String , List < String > > uFeatures ) { int tokUnified = 0 ; for ( int j = 0 ; j < tokSequence . size ( ) ; j ++ ) { boolean unifiedTokensFound = false ; for ( int i = 0 ; i < tokSequenceEquivalences . get ( j ) . size ( ) ; i ++ ) { int featUnified = 0 ; if ( tokS...
Make sure that we really matched all the required features of the unification .
12,795
public final void reset ( ) { equivalencesMatched . clear ( ) ; allFeatsIn = false ; tokCnt = 0 ; featuresFound . clear ( ) ; tmpFeaturesFound . clear ( ) ; tokSequence . clear ( ) ; tokSequenceEquivalences . clear ( ) ; readingsCounter = 1 ; uniMatched = false ; uniAllMatched = false ; inUnification = false ; }
Resets after use of unification . Required .
12,796
public final AnalyzedTokenReadings [ ] getUnifiedTokens ( ) { if ( tokSequence . isEmpty ( ) ) { return null ; } List < AnalyzedTokenReadings > uTokens = new ArrayList < > ( ) ; for ( int j = 0 ; j < tokSequence . size ( ) ; j ++ ) { boolean unifiedTokensFound = false ; for ( int i = 0 ; i < tokSequenceEquivalences . g...
Gets a full sequence of filtered tokens .
12,797
public final boolean isUnified ( AnalyzedToken matchToken , Map < String , List < String > > uFeatures , boolean lastReading , boolean isMatched ) { if ( inUnification ) { if ( isMatched ) { uniMatched |= isSatisfied ( matchToken , uFeatures ) ; } uniAllMatched = uniMatched ; if ( lastReading ) { startNextToken ( ) ; u...
Tests if the token sequence is unified .
12,798
protected boolean isSurrogatePairCombination ( String word ) { if ( word . length ( ) > 1 && word . length ( ) % 2 == 0 && word . codePointCount ( 0 , word . length ( ) ) != word . length ( ) ) { boolean isSurrogatePairCombination = true ; for ( int i = 0 ; i < word . length ( ) && isSurrogatePairCombination ; i += 2 )...
Checks whether a given String consists only of surrogate pairs .
12,799
public boolean canBeIgnoredFor ( AnalyzedSentence sentence ) { return ( ! simpleRuleTokens . isEmpty ( ) && ! sentence . getTokenSet ( ) . containsAll ( simpleRuleTokens ) ) || ( ! inflectedRuleTokens . isEmpty ( ) && ! sentence . getLemmaSet ( ) . containsAll ( inflectedRuleTokens ) ) ; }
A fast check whether this rule can be ignored for the given sentence because it can never match . Used internally for performance optimization .