idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
32,300 | public ClusterNode getRunnableNode ( RequestedNode requestedNode , LocalityLevel maxLevel , ResourceType type , Set < String > excluded ) { ClusterNode node = null ; RunnableIndices r = typeToIndices . get ( type ) ; node = r . getRunnableNodeForHost ( requestedNode ) ; if ( maxLevel == LocalityLevel . NODE || node != ... | Get a runnable node . |
32,301 | protected void addNode ( ClusterNode node , Map < ResourceType , String > resourceInfos ) { synchronized ( node ) { nameToNode . put ( node . getName ( ) , node ) ; faultManager . addNode ( node . getName ( ) , resourceInfos . keySet ( ) ) ; nameToApps . put ( node . getName ( ) , resourceInfos ) ; hostsToSessions . pu... | Add a node to be managed . |
32,302 | private void updateRunnability ( ClusterNode node ) { synchronized ( node ) { for ( Map . Entry < ResourceType , RunnableIndices > entry : typeToIndices . entrySet ( ) ) { ResourceType type = entry . getKey ( ) ; RunnableIndices r = entry . getValue ( ) ; ResourceRequest unitReq = Utilities . getUnitResourceRequest ( t... | Update the runnable status of a node based on resources available . This checks both resources and slot availability . |
32,303 | protected void addAppToNode ( ClusterNode node , ResourceType type , String appInfo ) { synchronized ( node ) { Map < ResourceType , String > apps = nameToApps . get ( node . getName ( ) ) ; apps . put ( type , appInfo ) ; for ( Map . Entry < ResourceType , RunnableIndices > entry : typeToIndices . entrySet ( ) ) { if ... | Register a new application on the node |
32,304 | public Set < String > getNodeSessions ( String nodeName ) { ClusterNode node = nameToNode . get ( nodeName ) ; if ( node == null ) { LOG . warn ( "Trying to get the sessions for a non-existent node " + nodeName ) ; return new HashSet < String > ( ) ; } synchronized ( node ) { return new HashSet < String > ( hostsToSess... | Get all the sessions that have grants on the node |
32,305 | public void deleteSession ( String session ) { for ( Set < String > sessions : hostsToSessions . values ( ) ) { sessions . remove ( session ) ; } } | Remove the references to the session |
32,306 | public void cancelGrant ( String nodeName , String sessionId , int requestId ) { ClusterNode node = nameToNode . get ( nodeName ) ; if ( node == null ) { LOG . warn ( "Canceling grant for non-existent node: " + nodeName ) ; return ; } synchronized ( node ) { if ( node . deleted ) { LOG . warn ( "Canceling grant for del... | Cancel grant on a node |
32,307 | public boolean addGrant ( ClusterNode node , String sessionId , ResourceRequestInfo req ) { synchronized ( node ) { if ( node . deleted ) { return false ; } if ( ! node . checkForGrant ( Utilities . getUnitResourceRequest ( req . getType ( ) ) , resourceLimit ) ) { return false ; } node . addGrant ( sessionId , req ) ;... | Add a grant to a node |
32,308 | public void restoreAfterSafeModeRestart ( ) throws IOException { if ( ! clusterManager . safeMode ) { throw new IOException ( "restoreAfterSafeModeRestart() called while the " + "Cluster Manager was not in Safe Mode" ) ; } for ( ClusterNode clusterNode : nameToNode . values ( ) ) { restoreClusterNode ( clusterNode ) ; ... | This method rebuilds members related to the NodeManager instance which were not directly persisted themselves . |
32,309 | public void restoreResourceRequestInfo ( ResourceRequestInfo resourceRequestInfo ) { List < RequestedNode > requestedNodes = null ; List < String > hosts = resourceRequestInfo . getHosts ( ) ; if ( hosts != null && hosts . size ( ) > 0 ) { requestedNodes = new ArrayList < RequestedNode > ( hosts . size ( ) ) ; for ( St... | This method rebuilds members related to a ResourceRequestInfo instance which were not directly persisted themselves . |
32,310 | public boolean heartbeat ( ClusterNodeInfo clusterNodeInfo ) throws DisallowedNode { ClusterNode node = nameToNode . get ( clusterNodeInfo . name ) ; if ( ! canAllowNode ( clusterNodeInfo . getAddress ( ) . getHost ( ) ) ) { if ( node != null ) { node . heartbeat ( clusterNodeInfo ) ; } else { throw new DisallowedNode ... | return true if a new node has been added - else return false |
32,311 | public String getAppInfo ( ClusterNode node , ResourceType type ) { Map < ResourceType , String > resourceInfos = nameToApps . get ( node . getName ( ) ) ; if ( resourceInfos == null ) { return null ; } else { return resourceInfos . get ( type ) ; } } | Get information about applications running on a node . |
32,312 | public int getAllocatedCpuForType ( ResourceType type ) { int total = 0 ; for ( ClusterNode node : nameToNode . values ( ) ) { synchronized ( node ) { if ( node . deleted ) { continue ; } total += node . getAllocatedCpuForType ( type ) ; } } return total ; } | Find allocation for a resource type . |
32,313 | public List < String > getFreeNodesForType ( ResourceType type ) { ArrayList < String > freeNodes = new ArrayList < String > ( ) ; for ( Map . Entry < String , ClusterNode > entry : nameToNode . entrySet ( ) ) { ClusterNode node = entry . getValue ( ) ; synchronized ( node ) { if ( ! node . deleted && node . getMaxCpuF... | Get a list nodes with free Cpu for a resource type |
32,314 | public void nodeFeedback ( String handle , List < ResourceType > resourceTypes , List < NodeUsageReport > reportList ) { for ( NodeUsageReport usageReport : reportList ) { faultManager . nodeFeedback ( usageReport . getNodeName ( ) , resourceTypes , usageReport ) ; } } | Process feedback about nodes . |
32,315 | void blacklistNode ( String nodeName , ResourceType resourceType ) { LOG . info ( "Node " + nodeName + " has been blacklisted for resource " + resourceType ) ; clusterManager . getMetrics ( ) . setBlacklistedNodes ( faultManager . getBlacklistedNodeCount ( ) ) ; deleteAppFromNode ( nodeName , resourceType ) ; } | Blacklist a resource on a node . |
32,316 | public RequestedNode resolve ( String host , ResourceType type ) { RunnableIndices indices = typeToIndices . get ( type ) ; return indices . getOrCreateRequestedNode ( host ) ; } | Resolve a host name . |
32,317 | public void resetNodesLastHeartbeatTime ( ) { long now = ClusterManager . clock . getTime ( ) ; for ( ClusterNode node : nameToNode . values ( ) ) { node . lastHeartbeatTime = now ; } } | This is required when we come out of safe mode and we need to reset the lastHeartbeatTime for each node |
32,318 | public void write ( JsonGenerator jsonGenerator ) throws IOException { jsonGenerator . writeStartObject ( ) ; jsonGenerator . writeFieldName ( "nameToNode" ) ; jsonGenerator . writeStartObject ( ) ; for ( Map . Entry < String , ClusterNode > entry : nameToNode . entrySet ( ) ) { jsonGenerator . writeFieldName ( entry .... | This method writes the state of the NodeManager to disk |
32,319 | public void setDelHints ( String delHints ) { if ( delHints == null || delHints . isEmpty ( ) ) { throw new IllegalArgumentException ( "DelHints is empty" ) ; } this . delHints = delHints ; } | Set this block s delHints |
32,320 | @ SuppressWarnings ( "unchecked" ) public void run ( RecordReader < K1 , V1 > input , OutputCollector < K2 , V2 > output , Reporter reporter ) throws IOException { Application < K1 , V1 , K2 , V2 > application = null ; try { RecordReader < FloatWritable , NullWritable > fakeInput = ( ! Submitter . getIsJavaRecordReader... | Run the map task . |
32,321 | static void printUsage ( ) { System . err . println ( "Usage: DFSck <path> [-list-corruptfileblocks | " + "[-move | -delete | -openforwrite ] " + "[-files [-blocks [-locations | -racks]]]] " + "[-limit <limit>] [-service serviceName]" + "[-(zero/one)]" ) ; System . err . println ( "\t<path>\tstart checking from this pa... | Print fsck usage information |
32,322 | private Integer listCorruptFileBlocks ( String dir , int limit , String baseUrl ) throws IOException { int errCode = - 1 ; int numCorrupt = 0 ; int cookie = 0 ; String lastBlock = null ; final String noCorruptLine = "has no CORRUPT files" ; final String noMoreCorruptLine = "has no more CORRUPT files" ; final String coo... | To get the list we need to call iteratively until the server says there is no more left . |
32,323 | private static void updateConfKeys ( Configuration conf , String suffix , String nameserviceId ) { String value = conf . get ( FSConstants . DFS_NAMENODE_HTTP_ADDRESS_KEY + suffix + ( nameserviceId . isEmpty ( ) ? "" : ( "." + nameserviceId ) ) ) ; if ( value != null ) { conf . set ( FSConstants . DFS_NAMENODE_HTTP_ADD... | For federated and avatar clusters we need update the http key . |
32,324 | private static boolean optionExist ( String args [ ] , String opt ) { for ( String arg : args ) { if ( arg . equalsIgnoreCase ( opt ) ) { return true ; } } return false ; } | Check if the option exist in the given arguments . |
32,325 | public static int parseHashType ( String name ) { if ( "jenkins" . equalsIgnoreCase ( name ) ) { return JENKINS_HASH ; } else if ( "murmur" . equalsIgnoreCase ( name ) ) { return MURMUR_HASH ; } else { return INVALID_HASH ; } } | This utility method converts String representation of hash function name to a symbolic constant . Currently two function types are supported jenkins and murmur . |
32,326 | public static Hash getInstance ( int type ) { switch ( type ) { case JENKINS_HASH : return JenkinsHash . getInstance ( ) ; case MURMUR_HASH : return MurmurHash . getInstance ( ) ; default : return null ; } } | Get a singleton instance of hash function of a given type . |
32,327 | public static int getVersion ( URI editsURI ) throws IOException { if ( editsURI . getScheme ( ) . equals ( NNStorage . LOCAL_URI_SCHEME ) ) { StorageDirectory sd = new NNStorage ( new StorageInfo ( ) ) . new StorageDirectory ( new File ( editsURI . getPath ( ) ) ) ; File versionFile = sd . getVersionFile ( ) ; if ( ! ... | Read version file from the given directory and return the layout stored therein . |
32,328 | public static File uriToFile ( URI u ) throws IOException { if ( ! u . getScheme ( ) . equals ( NNStorage . LOCAL_URI_SCHEME ) ) { throw new IOException ( "URI does not represent a file" ) ; } return new File ( u . getPath ( ) ) ; } | Get file associated with the given URI |
32,329 | public static List < String > getAllAncestors ( String eventPath ) { if ( eventPath == null || ! eventPath . startsWith ( Path . SEPARATOR ) ) { return null ; } if ( eventPath . equals ( Path . SEPARATOR ) ) { return Arrays . asList ( Path . SEPARATOR ) ; } List < String > ancestors = new ArrayList < String > ( ) ; whi... | return all the ancestors of the given path include itself . |
32,330 | synchronized public String addJob ( Job aJob ) { String id = this . getNextJobID ( ) ; aJob . setJobID ( id ) ; aJob . setState ( Job . WAITING ) ; this . addToQueue ( aJob ) ; return id ; } | Add a new job . |
32,331 | private synchronized void updateBlockInfo ( LogEntry e ) { BlockScanInfo info = blockMap . get ( new Block ( e . blockId , 0 , e . genStamp ) ) ; if ( info != null && e . verificationTime > 0 && info . lastScanTime < e . verificationTime ) { delBlockInfo ( info ) ; info . lastScanTime = e . verificationTime ; info . la... | Update blockMap by the given LogEntry |
32,332 | synchronized void addBlock ( Block block ) { if ( ! isInitialized ( ) ) { return ; } BlockScanInfo info = blockMap . get ( block ) ; if ( info != null ) { LOG . warn ( "Adding an already existing block " + block ) ; delBlockInfo ( info ) ; } info = new BlockScanInfo ( block ) ; info . lastScanTime = getNewBlockScanTime... | Adds block to list of blocks |
32,333 | synchronized void deleteBlock ( Block block ) { if ( ! isInitialized ( ) ) { return ; } BlockScanInfo info = blockMap . get ( block ) ; if ( info != null ) { delBlockInfo ( info ) ; } } | Deletes the block from internal structures |
32,334 | private void verifyFirstBlock ( ) { BlockScanInfo block = null ; synchronized ( this ) { if ( blockInfoSet . size ( ) > 0 ) { block = blockInfoSet . first ( ) ; } } if ( block != null ) { verifyBlock ( block ) ; processedBlocks . add ( block . block . getBlockId ( ) ) ; } } | Picks one block and verifies it |
32,335 | private static void checkSrcPath ( Configuration conf , List < Path > srcPaths ) throws IOException { List < IOException > rslt = new ArrayList < IOException > ( ) ; List < Path > unglobbed = new LinkedList < Path > ( ) ; for ( Path p : srcPaths ) { FileSystem fs = p . getFileSystem ( conf ) ; FileStatus [ ] inputs = f... | Sanity check for srcPath |
32,336 | public static DistCopier getCopier ( final Configuration conf , final Arguments args ) throws IOException { DistCopier dc = new DistCopier ( conf , args ) ; dc . setupJob ( ) ; if ( dc . getJobConf ( ) != null ) { return dc ; } else { return null ; } } | Return a DistCopier object for copying the files . |
32,337 | static void copy ( final Configuration conf , final Arguments args ) throws IOException { DistCopier copier = getCopier ( conf , args ) ; if ( copier != null ) { try { JobClient client = copier . getJobClient ( ) ; RunningJob job = client . submitJob ( copier . getJobConf ( ) ) ; try { if ( ! client . monitorAndPrintJo... | Driver to copy srcPath to destPath depending on required protocol . |
32,338 | public int run ( String [ ] args ) { try { copy ( conf , Arguments . valueOf ( args , conf ) ) ; return 0 ; } catch ( IllegalArgumentException e ) { System . err . println ( StringUtils . stringifyException ( e ) + "\n" + usage ) ; ToolRunner . printGenericCommandUsage ( System . err ) ; return - 1 ; } catch ( InvalidI... | This is the main driver for recursively copying directories across file systems . It takes at least two cmdline parameters . A source URL and a destination URL . It then essentially does an ls - lR on the source URL and writes the output in a round - robin manner to all the map input files . The mapper actually copies ... |
32,339 | static String makeRelative ( Path root , Path absPath ) { if ( ! absPath . isAbsolute ( ) ) { throw new IllegalArgumentException ( "!absPath.isAbsolute(), absPath=" + absPath ) ; } String p = absPath . toUri ( ) . getPath ( ) ; StringTokenizer pathTokens = new StringTokenizer ( p , "/" ) ; for ( StringTokenizer rootTok... | Make a path relative with respect to a root path . absPath is always assumed to descend from root . Otherwise returned path is null . |
32,340 | static void fullyDelete ( String dir , Configuration conf ) throws IOException { if ( dir != null ) { Path tmp = new Path ( dir ) ; tmp . getFileSystem ( conf ) . delete ( tmp , true ) ; } } | Fully delete dir |
32,341 | private static int setReducerCount ( long fileCount , JobConf job , JobClient client ) { int numReducers = Math . max ( job . getInt ( MAX_REDUCE_LABEL , MAX_REDUCERS_DEFAULT ) , ( int ) ( fileCount / job . getInt ( MAX_FILES_PER_REDUCER_LABEL , MAX_FILES_PER_REDUCER_DEFAULT ) ) ) ; numReducers = Math . max ( numReduce... | Calculate how many reducers to run . |
32,342 | static private boolean sameFile ( FileSystem srcfs , FileStatus srcstatus , FileSystem dstfs , Path dstpath , boolean skipCRCCheck ) throws IOException { FileStatus dststatus ; try { dststatus = dstfs . getFileStatus ( dstpath ) ; } catch ( FileNotFoundException fnfe ) { return false ; } if ( srcstatus . getLen ( ) != ... | Check whether the contents of src and dst are the same . |
32,343 | static private boolean isAncestorPath ( String x , String y ) { if ( ! y . startsWith ( x ) ) { return false ; } final int len = x . length ( ) ; return y . length ( ) == len || y . charAt ( len ) == Path . SEPARATOR_CHAR ; } | is x an ancestor path of y? |
32,344 | static private void checkDuplication ( FileSystem fs , Path file , Path sorted , Configuration conf ) throws IOException { SequenceFile . Reader in = null ; try { SequenceFile . Sorter sorter = new SequenceFile . Sorter ( fs , new Text . Comparator ( ) , Text . class , Text . class , conf ) ; sorter . sort ( file , sor... | Check whether the file list have duplication . |
32,345 | List < Job > getRemainingJobs ( ) { if ( mThread . isAlive ( ) ) { LOG . warn ( "Internal error: Polling running monitor for jobs" ) ; } synchronized ( mJobs ) { return new ArrayList < Job > ( mJobs ) ; } } | If shutdown before all jobs have completed any still - running jobs may be extracted from the component . |
32,346 | private static LocatedBlock convertLocatedBlock ( TLocatedBlock tblk ) { TBlock one = tblk . block ; Block hblock = new Block ( one . getBlockId ( ) , one . getNumBytes ( ) , one . getGenerationStamp ( ) ) ; List < TDatanodeID > locs = tblk . location ; DatanodeInfo [ ] dn = new DatanodeInfo [ locs . size ( ) ] ; for (... | Converts a TLocatedBlock to a LocatedBlock |
32,347 | private static Block convertBlock ( TBlock tblk ) { return new Block ( tblk . getBlockId ( ) , tblk . getNumBytes ( ) , tblk . getGenerationStamp ( ) ) ; } | Converts a TBlock to a Block |
32,348 | private ServerSocket createServerSocket ( int port ) throws IOException { try { ServerSocket sock = new ServerSocket ( ) ; sock . setReuseAddress ( true ) ; if ( port == 0 ) { sock . bind ( null ) ; serverPort = sock . getLocalPort ( ) ; } else { sock . bind ( new InetSocketAddress ( port ) ) ; } return sock ; } catch ... | Bind to port . If the specified port is 0 then bind to random port . |
32,349 | public void setArgs ( String args ) { for ( String s : args . trim ( ) . split ( "\\s*,\\s*" ) ) argv . add ( s ) ; } | Sets the argument list from a String of comma - separated values . |
32,350 | public void setOut ( String outprop ) { this . outprop = outprop ; out = new ByteArrayOutputStream ( ) ; if ( outprop . equals ( errprop ) ) err = out ; } | Sets the property into which System . out will be written . |
32,351 | public void setErr ( String errprop ) { this . errprop = errprop ; err = ( errprop . equals ( outprop ) ) ? err = out : new ByteArrayOutputStream ( ) ; } | Sets the property into which System . err will be written . If this property has the same name as the property for System . out the two will be interlaced . |
32,352 | protected void pushContext ( ) { antOut = System . out ; antErr = System . err ; System . setOut ( new PrintStream ( out ) ) ; System . setErr ( out == err ? System . out : new PrintStream ( err ) ) ; } | Save the current values of System . out System . err and configure output streams for FsShell . |
32,353 | protected void popContext ( ) { if ( outprop != null && ! System . out . checkError ( ) ) getProject ( ) . setNewProperty ( outprop , out . toString ( ) ) ; if ( out != err && errprop != null && ! System . err . checkError ( ) ) getProject ( ) . setNewProperty ( errprop , err . toString ( ) ) ; System . setErr ( antErr... | Create the appropriate output properties with their respective output restore System . out System . err and release any resources from created ClassLoaders to aid garbage collection . |
32,354 | private void printConf ( PrintWriter out , Reconfigurable reconf ) { Configuration oldConf = reconf . getConf ( ) ; Configuration newConf = new Configuration ( ) ; if ( reconf instanceof ReconfigurableBase ) ( ( ReconfigurableBase ) reconf ) . preProcessConfiguration ( newConf ) ; Collection < ReconfigurationUtil . Pro... | Print configuration options that can be changed . |
32,355 | private void applyChanges ( PrintWriter out , Reconfigurable reconf , HttpServletRequest req ) throws IOException , ReconfigurationException { Configuration oldConf = reconf . getConf ( ) ; Configuration newConf = new Configuration ( ) ; if ( reconf instanceof ReconfigurableBase ) ( ( ReconfigurableBase ) reconf ) . pr... | Apply configuration changes after admin has approved them . |
32,356 | public static boolean isCompatibleClientProtocol ( long clientVersion , long serverVersion ) { return clientVersion == serverVersion || ( ( clientVersion == ClientProtocol . OPTIMIZE_FILE_STATUS_VERSION - 1 || clientVersion == ClientProtocol . OPTIMIZE_FILE_STATUS_VERSION || clientVersion == ClientProtocol . ITERATIVE_... | Check if the client and NameNode have compatible ClientProtocol versions |
32,357 | public static boolean isCompatibleClientDatanodeProtocol ( long clientVersion , long serverVersion ) { return clientVersion == serverVersion || ( ( clientVersion == ClientDatanodeProtocol . GET_BLOCKINFO_VERSION - 1 || clientVersion == ClientDatanodeProtocol . GET_BLOCKINFO_VERSION || clientVersion == ClientDatanodePro... | Check if the client and DataNode have compatible ClientDataNodeProtocol versions |
32,358 | public void stop ( ) { if ( stopRequested ) { return ; } stopRequested = true ; running = false ; if ( server != null ) server . stop ( ) ; if ( triggerThread != null ) triggerThread . interrupt ( ) ; if ( fileFixer != null ) fileFixer . shutdown ( ) ; if ( fileFixerThread != null ) fileFixerThread . interrupt ( ) ; if... | Stop all HighTideNode threads and wait for all to finish . |
32,359 | void shutdown ( ) throws IOException , InterruptedException { configMgr . stopReload ( ) ; fileFixer . shutdown ( ) ; fileFixerThread . interrupt ( ) ; server . stop ( ) ; } | Shuts down the HighTideNode |
32,360 | public static HighTideNode createHighTideNode ( String argv [ ] , Configuration conf ) throws IOException { if ( conf == null ) { conf = new Configuration ( ) ; } StartupOption startOpt = parseArguments ( argv ) ; if ( startOpt == null ) { printUsage ( ) ; return null ; } setStartupOption ( conf , startOpt ) ; HighTide... | Create an instance of the HighTideNode |
32,361 | public static Path [ ] stat2Paths ( FileStatus [ ] stats ) { if ( stats == null ) return null ; Path [ ] ret = new Path [ stats . length ] ; for ( int i = 0 ; i < stats . length ; ++ i ) { ret [ i ] = stats [ i ] . getPath ( ) ; } return ret ; } | convert an array of FileStatus to an array of Path |
32,362 | public static Path [ ] stat2Paths ( FileStatus [ ] stats , Path path ) { if ( stats == null ) return new Path [ ] { path } ; else return stat2Paths ( stats ) ; } | convert an array of FileStatus to an array of Path . If stats if null return path |
32,363 | public static boolean fullyDelete ( File dir ) throws IOException { boolean deleted = true ; File contents [ ] = dir . listFiles ( ) ; if ( contents != null ) { for ( int i = 0 ; i < contents . length ; i ++ ) { if ( contents [ i ] . isFile ( ) ) { if ( ! contents [ i ] . delete ( ) ) { deleted = false ; } } else { boo... | Delete a directory and all its contents . If we return false the directory may be partially - deleted . |
32,364 | public static void fullyDelete ( FileSystem fs , Path dir ) throws IOException { fs . delete ( dir , true ) ; } | Recursively delete a directory . |
32,365 | public static boolean copy ( FileSystem srcFS , Path src , FileSystem dstFS , Path dst , boolean deleteSource , Configuration conf ) throws IOException { return copy ( srcFS , src , dstFS , dst , deleteSource , true , conf ) ; } | Copy files between FileSystems . |
32,366 | public static boolean copy ( FileSystem srcFS , Path src , FileSystem dstFS , Path dst , boolean deleteSource , boolean overwrite , boolean validate , Configuration conf , IOThrottler throttler ) throws IOException { dst = checkDest ( src . getName ( ) , dstFS , dst , overwrite ) ; FileStatus srcFileStatus = srcFS . ge... | Copy files between file systems |
32,367 | public static boolean copy ( File src , FileSystem dstFS , Path dst , boolean deleteSource , Configuration conf ) throws IOException { dst = checkDest ( src . getName ( ) , dstFS , dst , false ) ; if ( src . isDirectory ( ) ) { if ( ! dstFS . mkdirs ( dst ) ) { return false ; } File contents [ ] = src . listFiles ( ) ;... | Copy local files to a FileSystem . |
32,368 | public static boolean copy ( FileSystem srcFS , Path src , File dst , boolean deleteSource , Configuration conf ) throws IOException { return copy ( srcFS , src , dst , deleteSource , conf , false , 0L ) ; } | Copy FileSystem files to local files . |
32,369 | public static long getDU ( File dir ) { long size = 0 ; if ( ! dir . exists ( ) ) return 0 ; if ( ! dir . isDirectory ( ) ) { return dir . length ( ) ; } else { size = dir . length ( ) ; File [ ] allFiles = dir . listFiles ( ) ; for ( int i = 0 ; i < allFiles . length ; i ++ ) { size = size + getDU ( allFiles [ i ] ) ;... | Takes an input dir and returns the du on that local directory . Very basic implementation . |
32,370 | public static void unZip ( File inFile , File unzipDir ) throws IOException { Enumeration < ? extends ZipEntry > entries ; ZipFile zipFile = new ZipFile ( inFile ) ; try { entries = zipFile . entries ( ) ; while ( entries . hasMoreElements ( ) ) { ZipEntry entry = entries . nextElement ( ) ; if ( ! entry . isDirectory ... | Given a File input it will unzip the file in a the unzip directory passed as the second parameter |
32,371 | public static void unTar ( File inFile , File untarDir ) throws IOException { if ( ! untarDir . mkdirs ( ) ) { if ( ! untarDir . isDirectory ( ) ) { throw new IOException ( "Mkdirs failed to create " + untarDir ) ; } } StringBuffer untarCommand = new StringBuffer ( ) ; boolean gzipped = inFile . toString ( ) . endsWith... | Given a Tar File as input it will untar the file in a the untar directory passed as the second parameter |
32,372 | public static int symLink ( String target , String linkname ) throws IOException { String cmd = "ln -s " + target + " " + linkname ; Process p = Runtime . getRuntime ( ) . exec ( cmd , null ) ; int returnVal = - 1 ; try { returnVal = p . waitFor ( ) ; } catch ( InterruptedException e ) { } return returnVal ; } | Create a soft link between a src and destination only on a local disk . HDFS does not support this |
32,373 | public static int chmod ( String filename , String perm ) throws IOException , InterruptedException { return chmod ( filename , perm , false ) ; } | Change the permissions on a filename . |
32,374 | public static final File createLocalTempFile ( final File basefile , final String prefix , final boolean isDeleteOnExit ) throws IOException { File tmp = File . createTempFile ( prefix + basefile . getName ( ) , "" , basefile . getParentFile ( ) ) ; if ( isDeleteOnExit ) { tmp . deleteOnExit ( ) ; } return tmp ; } | Create a tmp file for a base file . |
32,375 | public static List < FileStatus > listStatusHelper ( FileSystem fs , Path path , int depth , List < FileStatus > acc ) throws IOException { FileStatus [ ] fileStatusResults = fs . listStatus ( path ) ; if ( fileStatusResults == null ) { throw new IOException ( "Path does not exist: " + path ) ; } for ( FileStatus f : f... | Core logic for listStatus |
32,376 | public static void listStatusForLeafDir ( FileSystem fs , FileStatus pathStatus , List < FileStatus > acc ) throws IOException { if ( ! pathStatus . isDir ( ) ) return ; FileStatus [ ] fileStatusResults = fs . listStatus ( pathStatus . getPath ( ) ) ; if ( fileStatusResults == null ) { throw new IOException ( "Path doe... | pass in a directory path get the list of statuses of leaf directories |
32,377 | public static void replaceFile ( File src , File target ) throws IOException { if ( ! src . renameTo ( target ) ) { int retries = 5 ; while ( target . exists ( ) && ! target . delete ( ) && retries -- >= 0 ) { try { Thread . sleep ( 1000 ) ; } catch ( InterruptedException e ) { throw new IOException ( "replaceFile inte... | Move the src file to the name specified by target . |
32,378 | public Iterator < Writable > iterator ( ) { final TupleWritable t = this ; return new Iterator < Writable > ( ) { long i = written ; long last = 0L ; public boolean hasNext ( ) { return 0L != i ; } public Writable next ( ) { last = Long . lowestOneBit ( i ) ; if ( 0 == last ) throw new NoSuchElementException ( ) ; i ^=... | Return an iterator over the elements in this tuple . Note that this doesn t flatten the tuple ; one may receive tuples from this iterator . |
32,379 | public void close ( ) throws IOException { if ( currentOffset < dataLength ) { byte [ ] t = new byte [ Math . min ( ( int ) ( Integer . MAX_VALUE & ( dataLength - currentOffset ) ) , 32 * 1024 ) ] ; while ( currentOffset < dataLength ) { int n = read ( t , 0 , t . length ) ; if ( 0 == n ) { throw new EOFException ( "Co... | Close the input stream . Note that we need to read to the end of the stream to validate the checksum . |
32,380 | public int read ( byte [ ] b , int off , int len ) throws IOException { if ( currentOffset >= dataLength ) { return - 1 ; } return doRead ( b , off , len ) ; } | Read bytes from the stream . At EOF checksum is validated but the checksum bytes are not passed back in the buffer . |
32,381 | public int readWithChecksum ( byte [ ] b , int off , int len ) throws IOException { if ( currentOffset == length ) { return - 1 ; } else if ( currentOffset >= dataLength ) { int lenToCopy = ( int ) ( checksumSize - ( currentOffset - dataLength ) ) ; if ( len < lenToCopy ) { lenToCopy = len ; } System . arraycopy ( csum... | Read bytes from the stream . At EOF checksum is validated and sent back as the last four bytes of the buffer . The caller should handle these bytes appropriately |
32,382 | private Map < String , List < ResourceGrant > > scheduleTasks ( ) { fullyScheduled = false ; long nodeWait = configManager . getLocalityWait ( type , LocalityLevel . NODE ) ; long rackWait = configManager . getLocalityWait ( type , LocalityLevel . RACK ) ; int tasksToSchedule = configManager . getGrantsPerIteration ( )... | Match requests to nodes . |
32,383 | private ScheduledPair scheduleOneTask ( long nodeWait , long rackWait ) { if ( ! nodeManager . existRunnableNodes ( type ) ) { return null ; } Queue < PoolGroupSchedulable > poolGroupQueue = poolGroupManager . getScheduleQueue ( ) ; while ( ! poolGroupQueue . isEmpty ( ) ) { PoolGroupSchedulable poolGroup = poolGroupQu... | Try match one request to one node |
32,384 | private MatchedPair doMatch ( SessionSchedulable schedulable , long now , long nodeWait , long rackWait ) { schedulable . adjustLocalityRequirement ( now , nodeWait , rackWait ) ; for ( LocalityLevel level : neededLocalityLevels ) { if ( level . isBetterThan ( schedulable . getLastLocality ( ) ) ) { continue ; } if ( n... | Find a node to give resources to this schedulable session . |
32,385 | private MatchedPair matchNodeForSession ( Session session , LocalityLevel level ) { Iterator < ResourceRequestInfo > pendingRequestIterator = session . getPendingRequestIteratorForType ( type ) ; while ( pendingRequestIterator . hasNext ( ) ) { ResourceRequestInfo req = pendingRequestIterator . next ( ) ; Set < String ... | Find a matching pair of node request by looping through the requests in the session looking at the hosts in each request and making look - ups into the node manager . |
32,386 | private MatchedPair matchSessionForNode ( Session session , LocalityLevel level ) { if ( level == LocalityLevel . NODE || level == LocalityLevel . ANY ) { Set < Map . Entry < String , NodeContainer > > hostNodesSet = nodeSnapshot . runnableHosts ( ) ; for ( Map . Entry < String , NodeContainer > hostNodes : hostNodesSe... | Find a matching pair of node request by looping through runnable nodes in the node snapshot created earlier . For each node we make lookups in the session to find a suitable request . |
32,387 | private boolean needLocalityCheck ( LocalityLevel level , long nodeWait , long rackWait ) { if ( level == LocalityLevel . NODE ) { return nodeWait != 0 ; } if ( level == LocalityLevel . RACK ) { return rackWait != 0 ; } return false ; } | If the locality wait time is zero we don t need to check locality at all . |
32,388 | private ResourceGrant commitMatchedResource ( Session session , MatchedPair pair ) { ResourceGrant grant = null ; ResourceRequestInfo req = pair . req ; ClusterNode node = pair . node ; String appInfo = nodeManager . getAppInfo ( node , type ) ; if ( appInfo != null ) { if ( nodeManager . addGrant ( node , session . ge... | Given a session and match of request - node perform a transaction commit |
32,389 | private void doPreemption ( ) { long now = ClusterManager . clock . getTime ( ) ; if ( now - lastPreemptionTime > PREEMPTION_PERIOD ) { lastPreemptionTime = now ; doPreemptionNow ( ) ; } } | Performs preemption if it has been long enough since the last round . |
32,390 | private void doPreemptionNow ( ) { int totalShare = nodeManager . getAllocatedCpuForType ( type ) ; poolGroupManager . distributeShare ( totalShare ) ; for ( PoolGroupSchedulable poolGroup : poolGroupManager . getPoolGroups ( ) ) { poolGroup . distributeShare ( ) ; } int tasksToPreempt = countTasksShouldPreempt ( ) ; i... | Performs the preemption . |
32,391 | private void preemptTasks ( int tasksToPreempt ) { LOG . info ( "Start preempt " + tasksToPreempt + " for type " + type ) ; long maxRunningTime = configManager . getPreemptedTaskMaxRunningTime ( ) ; int rounds = configManager . getPreemptionRounds ( ) ; while ( tasksToPreempt > 0 ) { int preempted = preemptOneSession (... | Kill tasks from over - scheduled sessions |
32,392 | private int preemptOneSession ( int maxToPreemt , long maxRunningTime ) { Queue < PoolGroupSchedulable > poolGroupQueue = poolGroupManager . getPreemptQueue ( ) ; while ( ! poolGroupQueue . isEmpty ( ) ) { PoolGroupSchedulable poolGroup = poolGroupQueue . poll ( ) ; poolGroup . distributeShare ( ) ; Queue < PoolSchedul... | Find the most over - scheduled session in the most over - scheduled pool . Kill tasks from this session . |
32,393 | private int preemptSession ( SessionSchedulable schedulable , int maxToPreemt , long maxRunningTime ) throws InvalidSessionHandle { Session session = schedulable . getSession ( ) ; List < Integer > grantIds ; synchronized ( session ) { grantIds = session . getGrantsToPreempt ( maxToPreemt , maxRunningTime , type ) ; } ... | Preempt a session . |
32,394 | private int countTasksShouldPreempt ( ) { int tasksToPreempt = 0 ; long now = ClusterManager . clock . getTime ( ) ; for ( PoolGroupSchedulable poolGroup : poolGroupManager . getPoolGroups ( ) ) { for ( PoolSchedulable pool : poolGroup . getPools ( ) ) { if ( pool . isStarving ( now ) ) { tasksToPreempt += Math . min (... | Count how many tasks should preempt for the starving pools |
32,395 | public void addSession ( String id , Session session ) { poolGroupManager . addSession ( id , session ) ; LOG . info ( "Session " + id + " has been added to " + type + " scheduler" ) ; } | Add a session to this scheduler . |
32,396 | public static < K extends WritableComparable , V extends Writable > Writable getEntry ( MapFile . Reader [ ] readers , Partitioner < K , V > partitioner , K key , V value ) throws IOException { int part = partitioner . getPartition ( key , value , readers . length ) ; return readers [ part ] . get ( key , value ) ; } | Get an entry from output generated by this class . |
32,397 | public void monitor ( LocalStore ls ) { int in = 0 ; EventRecord er = null ; Environment . logInfo ( "Started processing log..." ) ; while ( ( er = getNext ( ) ) != null ) { if ( er . isValid ( ) ) { ls . insert ( er ) ; } } PersistentState . updateState ( file . getAbsolutePath ( ) , firstLine , offset ) ; PersistentS... | Insert all EventRecords that can be extracted for the represented hardware component into a LocalStore . |
32,398 | public EventRecord [ ] monitor ( ) { ArrayList < EventRecord > recs = new ArrayList < EventRecord > ( ) ; EventRecord er ; while ( ( er = getNext ( ) ) != null ) recs . add ( er ) ; EventRecord [ ] T = new EventRecord [ recs . size ( ) ] ; return recs . toArray ( T ) ; } | Get an array of all EventRecords that can be extracted for the represented hardware component . |
32,399 | public EventRecord getNext ( ) { try { String line = reader . readLine ( ) ; if ( line != null ) { if ( firstLine == null ) firstLine = new String ( line ) ; offset += line . length ( ) + 1 ; return parseLine ( line ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } return null ; } | Continue parsing the log file until a valid log entry is identified . When one such entry is found parse it and return a corresponding EventRecord . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.