idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
32,400 | public void checkForRotation ( ) { try { BufferedReader probe = new BufferedReader ( new FileReader ( file . getAbsoluteFile ( ) ) ) ; if ( firstLine == null || ( ! firstLine . equals ( probe . readLine ( ) ) ) ) { probe . close ( ) ; reader . close ( ) ; reader = new BufferedReader ( new FileReader ( file . getAbsolut... | Check whether the log file has been rotated . If so start reading the file from the beginning . |
32,401 | public static int getPartitionStatic ( LongWritable key , LongWritable value , int numPartitions ) { return ( int ) ( Math . abs ( key . get ( ) ) % numPartitions ) ; } | Get a partition from the key only |
32,402 | private static int getMapperId ( long key , int numReducers , int maxKeySpace ) { key = key - getFirstSumKey ( numReducers , maxKeySpace ) ; return ( int ) ( key / numReducers ) ; } | Which mapper sent this key sum? |
32,403 | public static int getAttemptId ( Configuration conf ) throws IllegalArgumentException { if ( conf == null ) { throw new NullPointerException ( "Conf is null" ) ; } String taskId = conf . get ( "mapred.task.id" ) ; if ( taskId == null ) { throw new IllegalArgumentException ( "Configuration does not contain the property ... | Get the attempt number |
32,404 | public void updateRegInfo ( DatanodeID nodeReg ) { name = nodeReg . getName ( ) ; infoPort = nodeReg . getInfoPort ( ) ; ipcPort = nodeReg . getIpcPort ( ) ; } | Update fields when a new registration request comes in . Note that this does not update storageID . |
32,405 | public void decodeBulk ( byte [ ] [ ] readBufs , byte [ ] [ ] writeBufs , int [ ] erasedLocations ) throws IOException { int [ ] tmpInput = new int [ readBufs . length ] ; int [ ] tmpOutput = new int [ erasedLocations . length ] ; int numBytes = readBufs [ 0 ] . length ; for ( int idx = 0 ; idx < numBytes ; idx ++ ) { ... | This method would be overridden in the subclass so that the subclass will have its own decodeBulk behavior . |
32,406 | static Comparer < byte [ ] > getBestComparer ( ) { try { Class < ? > theClass = Class . forName ( UNSAFE_COMPARER_NAME ) ; @ SuppressWarnings ( "unchecked" ) Comparer < byte [ ] > comparer = ( Comparer < byte [ ] > ) theClass . getEnumConstants ( ) [ 0 ] ; return comparer ; } catch ( Throwable t ) { LOG . error ( "Load... | Returns the Unsafe - using Comparer or falls back to the pure - Java implementation if unable to do so . |
32,407 | public String [ ] getAttributeNames ( ) { String [ ] result = new String [ attributeMap . size ( ) ] ; int i = 0 ; Iterator it = attributeMap . keySet ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { result [ i ++ ] = ( String ) it . next ( ) ; } return result ; } | Returns the names of all the factory s attributes . |
32,408 | public static synchronized MetricsContext getNullContext ( String contextName ) { MetricsContext nullContext = nullContextMap . get ( contextName ) ; if ( nullContext == null ) { nullContext = new NullContext ( ) ; nullContextMap . put ( contextName , nullContext ) ; } return nullContext ; } | Returns a null context - one which does nothing . |
32,409 | public List < String > parse ( String [ ] args , int pos ) { List < String > parameters = new ArrayList < String > ( ) ; for ( ; pos < args . length ; pos ++ ) { if ( args [ pos ] . charAt ( 0 ) == '-' && args [ pos ] . length ( ) > 1 ) { String opt = args [ pos ] . substring ( 1 ) ; if ( options . containsKey ( opt ) ... | Parse parameters starting from the given position |
32,410 | public void emitRecord ( String contextName , String recordName , OutputRecord outRec ) throws IOException { Calendar currentDate = Calendar . getInstance ( ) ; if ( fileName != null ) { if ( currentDate . get ( Calendar . DAY_OF_MONTH ) != lastRecordDate . get ( Calendar . DAY_OF_MONTH ) ) { file = new File ( getFullF... | Emits a metrics record to a file . |
32,411 | private void adjustChecksumBytes ( int dataLen ) { int requiredSize = ( ( dataLen + bytesPerChecksum - 1 ) / bytesPerChecksum ) * checksumSize ; if ( checksumBytes == null || requiredSize > checksumBytes . capacity ( ) ) { checksumBytes = ByteBuffer . wrap ( new byte [ requiredSize ] ) ; } else { checksumBytes . clear ... | Makes sure that checksumBytes has enough capacity and limit is set to the number of checksum bytes needed to be read . |
32,412 | private synchronized void readBlockSizeInfo ( ) throws IOException { if ( ! transferBlockSize ) { return ; } blkLenInfoUpdated = true ; isBlockFinalized = in . readBoolean ( ) ; updatedBlockLength = in . readLong ( ) ; if ( dataTransferVersion >= DataTransferProtocol . READ_PROFILING_VERSION ) { readDataNodeProfilingDa... | Read the block length information from data stream |
32,413 | public static BlockReader newBlockReader ( int dataTransferVersion , int namespaceId , Socket sock , String file , long blockId , long genStamp , long startOffset , long len , int bufferSize , boolean verifyChecksum ) throws IOException { return newBlockReader ( dataTransferVersion , namespaceId , sock , file , blockId... | Java Doc required |
32,414 | protected RunningJob createRunningJob ( JobID jobId , TaskInProgress tip ) throws IOException { CoronaSessionInfo info = ( CoronaSessionInfo ) ( tip . getExtensible ( ) ) ; RunningJob rJob = new RunningJob ( jobId , null , info ) ; JobTrackerReporter reporter = new JobTrackerReporter ( rJob , info . getJobTrackerAddr (... | Override this method to create the proper jobClient and the thread that sends jobTracker heartbeat . |
32,415 | protected synchronized void purgeJob ( KillJobAction action ) throws IOException { JobID jobId = action . getJobID ( ) ; JobTrackerReporter reporter = jobTrackerReporters . remove ( jobId ) ; if ( reporter != null ) { reporter . shutdown ( ) ; } super . purgeJob ( action ) ; crReleaseManager . returnRelease ( jobId ) ;... | Override this to shutdown the heartbeat the the corresponding jobtracker |
32,416 | void launchTaskJVM ( TaskController . TaskControllerContext context ) throws IOException { JvmEnv env = context . env ; List < String > wrappedCommand = TaskLog . captureOutAndError ( env . setup , env . vargs , env . stdout , env . stderr , env . logSize , true ) ; ShellCommandExecutor shexec = new ShellCommandExecuto... | Launch a new JVM for the task . |
32,417 | void refresh ( ) { if ( this . viewer == null ) return ; Display . getDefault ( ) . asyncExec ( new Runnable ( ) { public void run ( ) { DFSContentProvider . this . viewer . refresh ( ) ; } } ) ; } | Ask the viewer for this content to refresh |
32,418 | void refresh ( final DFSContent content ) { if ( this . sviewer != null ) { Display . getDefault ( ) . asyncExec ( new Runnable ( ) { public void run ( ) { DFSContentProvider . this . sviewer . refresh ( content ) ; } } ) ; } else { refresh ( ) ; } } | Ask the viewer to refresh a single element |
32,419 | public static String getTaskLogUrl ( String taskTrackerHostName , String httpPort , String taskAttemptID ) { return ( "http://" + taskTrackerHostName + ":" + httpPort + "/tasklog?taskid=" + taskAttemptID ) ; } | Construct the taskLogUrl |
32,420 | private static int findFirstQuotable ( byte [ ] data , int offset , int end ) { while ( offset < end ) { switch ( data [ offset ] ) { case '<' : case '>' : case '&' : return offset ; default : offset += 1 ; } } return offset ; } | Find the next quotable character in the given array . |
32,421 | public void snapshot ( ) { snapshotPoolGroups = new ArrayList < PoolGroupSchedulable > ( nameToPoolGroup . values ( ) ) ; for ( PoolGroupSchedulable poolGroup : snapshotPoolGroups ) { poolGroup . snapshot ( ) ; } scheduleQueue = null ; preemptQueue = null ; Collection < PoolInfo > configuredPoolInfos = configManager . ... | Take snapshots for all pools groups and sessions . |
32,422 | public Queue < PoolGroupSchedulable > getScheduleQueue ( ) { if ( scheduleQueue == null ) { scheduleQueue = createPoolGroupQueue ( ScheduleComparator . FAIR ) ; } return scheduleQueue ; } | Get the queue of pool groups sorted for scheduling |
32,423 | public Queue < PoolGroupSchedulable > getPreemptQueue ( ) { if ( preemptQueue == null ) { preemptQueue = createPoolGroupQueue ( ScheduleComparator . FAIR_PREEMPT ) ; } return preemptQueue ; } | Get the queue of the pool groups sorted for preemption |
32,424 | private Queue < PoolGroupSchedulable > createPoolGroupQueue ( ScheduleComparator comparator ) { int initCapacity = snapshotPoolGroups . size ( ) == 0 ? 1 : snapshotPoolGroups . size ( ) ; Queue < PoolGroupSchedulable > poolGroupQueue = new PriorityQueue < PoolGroupSchedulable > ( initCapacity , comparator ) ; poolGroup... | Put all the pool groups into the priority queue sorted by a comparator |
32,425 | public void addSession ( String id , Session session ) { PoolInfo poolInfo = getPoolInfo ( session ) ; LOG . info ( "Session " + id + " added to pool info " + poolInfo + " (originally " + session . getInfo ( ) . getPoolInfoStrings ( ) + ") for " + type ) ; getPoolSchedulable ( poolInfo ) . addSession ( id , session ) ;... | Add a session to the scheduler |
32,426 | public static void checkPoolInfoIfStrict ( PoolInfo poolInfo , ConfigManager configManager , CoronaConf conf ) throws InvalidSessionHandle { if ( ! conf . onlyAllowConfiguredPools ( ) ) { return ; } if ( poolInfo == null ) { throw new InvalidSessionHandle ( "This cluster is operating in " + "configured pools only mode.... | If the cluster is set to configured pools only do not allow unset pool information or pool info that doesn t match a valid pool info . Throws an InvalidSessionHandle exception in either of the failure cases . |
32,427 | public static PoolInfo getPoolInfo ( Session session ) { PoolInfo poolInfo = session . getPoolInfo ( ) ; if ( poolInfo == null || poolInfo . getPoolName ( ) . equals ( "" ) ) { poolInfo = new PoolInfo ( DEFAULT_POOL_GROUP , session . getUserId ( ) ) ; } if ( ! PoolInfo . isLegalPoolInfo ( poolInfo ) ) { LOG . warn ( "I... | Get the pool name for a given session using the default pool information if the name is illegal . Redirection should happen prior to this . |
32,428 | private PoolSchedulable getPoolSchedulable ( PoolInfo poolInfo ) { PoolGroupSchedulable poolGroup = nameToPoolGroup . get ( poolInfo . getPoolGroupName ( ) ) ; if ( poolGroup == null ) { poolGroup = new PoolGroupSchedulable ( poolInfo . getPoolGroupName ( ) , type , configManager ) ; PoolGroupSchedulable prevPoolGroup ... | Get the Schedulable representing the pool with a given name If it doesn t exist - create it and add it to the list |
32,429 | public static int ioprioGetIfPossible ( ) throws IOException { if ( nativeLoaded && ioprioPossible ) { try { return ioprio_get ( ) ; } catch ( UnsupportedOperationException uoe ) { LOG . warn ( "ioprioGetIfPossible() failed" , uoe ) ; ioprioPossible = false ; } catch ( UnsatisfiedLinkError ule ) { LOG . warn ( "ioprioG... | Call ioprio_get for this thread . |
32,430 | public static void posixFadviseIfPossible ( FileDescriptor fd , long offset , long len , int flags ) throws NativeIOException { if ( nativeLoaded && fadvisePossible ) { try { posix_fadvise ( fd , offset , len , flags ) ; InjectionHandler . processEvent ( InjectionEventCore . NATIVEIO_POSIX_FADVISE , flags ) ; } catch (... | Call posix_fadvise on the given file descriptor . See the manpage for this syscall for more information . On systems where this call is not available does nothing . |
32,431 | public static void syncFileRangeIfPossible ( FileDescriptor fd , long offset , long nbytes , int flags ) throws NativeIOException { InjectionHandler . processEvent ( InjectionEventCore . NATIVEIO_SYNC_FILE_RANGE , flags ) ; if ( nativeLoaded && syncFileRangePossible ) { try { sync_file_range ( fd , offset , nbytes , fl... | Call sync_file_range on the given file descriptor . See the manpage for this syscall for more information . On systems where this call is not available does nothing . |
32,432 | public static WriteOptions writeOptions ( Boolean overwrite , Boolean forceSync ) { WriteOptions wo = new WriteOptions ( ) ; if ( overwrite != null ) wo . setOverwrite ( overwrite ) ; if ( forceSync != null ) wo . setForcesync ( forceSync ) ; return wo ; } | Creates a WriteOptions from given overwrite and forceSync values . If null passed it will use their default value . |
32,433 | public static CreateOptions getOpt ( Class < ? extends CreateOptions > theClass , CreateOptions ... opts ) { if ( opts == null ) return null ; CreateOptions result = null ; for ( int i = 0 ; i < opts . length ; ++ i ) { if ( opts [ i ] . getClass ( ) == theClass ) { if ( result != null ) throw new IllegalArgumentExcept... | Get an option of desired type |
32,434 | public static < T extends CreateOptions > CreateOptions [ ] setOpt ( T newValue , CreateOptions ... opts ) { boolean alreadyInOpts = false ; if ( opts != null ) { for ( int i = 0 ; i < opts . length ; ++ i ) { if ( opts [ i ] . getClass ( ) == newValue . getClass ( ) ) { if ( alreadyInOpts ) throw new IllegalArgumentEx... | set an option |
32,435 | private void handleMirrorOutError ( IOException ioe ) throws IOException { LOG . info ( datanode . getDatanodeInfo ( ) + ": Exception writing block " + block + " namespaceId: " + namespaceId + " to mirror " + mirrorAddr + "\n" + StringUtils . stringifyException ( ioe ) ) ; if ( Thread . interrupted ( ) ) { throw ioe ; ... | While writing to mirrorOut failure to write to mirror should not affect this datanode . |
32,436 | private void verifyChunks ( byte [ ] dataBuf , int dataOff , int len , byte [ ] checksumBuf , int checksumOff , int firstChunkOffset , int packetVersion ) throws IOException { int chunkOffset = firstChunkOffset ; while ( len > 0 ) { int chunkLen = Math . min ( len , bytesPerChecksum - chunkOffset ) ; chunkOffset = 0 ; ... | Verify multiple CRC chunks . |
32,437 | public static URI stringAsURI ( String s ) throws IOException { URI u = null ; try { u = new URI ( s ) ; } catch ( URISyntaxException e ) { LOG . error ( "Syntax error in URI " + s + ". Please check hdfs configuration." , e ) ; } if ( u == null || u . getScheme ( ) == null ) { LOG . warn ( "Path " + s + " should be spe... | Interprets the passed string as a URI . In case of error it assumes the specified string is a file . |
32,438 | public static Collection < URI > stringCollectionAsURIs ( Collection < String > names ) { Collection < URI > uris = new ArrayList < URI > ( names . size ( ) ) ; for ( String name : names ) { try { uris . add ( stringAsURI ( name ) ) ; } catch ( IOException e ) { LOG . error ( "Error while processing URI: " + name , e )... | Converts a collection of strings into a collection of URIs . |
32,439 | static String getRealTaskLogFilePath ( String location , LogName filter ) throws IOException { return FileUtil . makeShellPath ( new File ( getBaseDir ( location ) , filter . toString ( ) ) ) ; } | Get the real task - log file - path |
32,440 | public static List < String > captureOutAndError ( List < String > cmd , File stdoutFilename , File stderrFilename , long tailLength ) throws IOException { return captureOutAndError ( null , cmd , stdoutFilename , stderrFilename , tailLength , false ) ; } | Wrap a command in a shell to capture stdout and stderr to files . If the tailLength is 0 the entire output will be saved . |
32,441 | public static List < String > captureOutAndError ( List < String > setup , List < String > cmd , File stdoutFilename , File stderrFilename , long tailLength , boolean useSetsid ) throws IOException { List < String > result = new ArrayList < String > ( 3 ) ; result . add ( bashCommand ) ; result . add ( "-c" ) ; String ... | Wrap a command in a shell to capture stdout and stderr to files . Setup commands such as setting memory limit can be passed which will be executed before exec . If the tailLength is 0 the entire output will be saved . |
32,442 | public static String addCommand ( List < String > cmd , boolean isExecutable ) throws IOException { StringBuffer command = new StringBuffer ( ) ; for ( String s : cmd ) { command . append ( '\'' ) ; if ( isExecutable ) { command . append ( FileUtil . makeShellPath ( new File ( s ) ) ) ; isExecutable = false ; } else { ... | Add quotes to each of the command strings and return as a single string |
32,443 | public static List < String > captureDebugOut ( List < String > cmd , File debugoutFilename ) throws IOException { String debugout = FileUtil . makeShellPath ( debugoutFilename ) ; List < String > result = new ArrayList < String > ( 3 ) ; result . add ( bashCommand ) ; result . add ( "-c" ) ; StringBuffer mergedCmd = n... | Wrap a command in a shell to capture debug script s stdout and stderr to debugout . |
32,444 | public void start ( ) { if ( refreshInterval > 0 ) { refreshUsed = new Thread ( new DURefreshThread ( ) , "refreshUsed-" + dirPath ) ; refreshUsed . setDaemon ( true ) ; refreshUsed . start ( ) ; } } | Start the disk usage checking thread . |
32,445 | public void shutdown ( ) { this . shouldRun = false ; this . namespaceSliceDUMap . clear ( ) ; if ( this . refreshUsed != null ) { this . refreshUsed . interrupt ( ) ; try { this . refreshUsed . join ( ) ; this . refreshUsed = null ; } catch ( InterruptedException ie ) { } } } | Shut down the refreshing thread . |
32,446 | private int killSession ( String sessionId ) throws IOException { try { System . out . printf ( "Killing %s" , sessionId ) ; ClusterManagerService . Client client = getCMSClient ( ) ; try { client . killSession ( sessionId ) ; } catch ( SafeModeException e ) { throw new IOException ( "Cannot kill session yet, ClusterMa... | Tells the cluster manager to kill the session with a given id |
32,447 | private int listSessions ( ) throws IOException { try { ClusterManagerService . Client client = getCMSClient ( ) ; List < RunningSession > sessions ; try { sessions = client . getSessions ( ) ; } catch ( SafeModeException e ) { throw new IOException ( "Cannot list sessions, ClusterManager is in Safe Mode" ) ; } System ... | Gets a list of the sessions from the cluster manager and outputs them on the console |
32,448 | static public EditsVisitor getEditsVisitor ( String filename , String processor , Tokenizer tokenizer , boolean printToScreen ) throws IOException { if ( processor . toLowerCase ( ) . equals ( "xml" ) ) { return new XmlEditsVisitor ( filename , tokenizer , printToScreen ) ; } else if ( processor . toLowerCase ( ) . equ... | Factory function that creates an EditsVisitor object |
32,449 | private void runCommand ( TaskCommands taskCommand , String user , List < String > cmdArgs , File workDir , Map < String , String > env ) throws IOException { ShellCommandExecutor shExec = buildTaskControllerExecutor ( taskCommand , user , cmdArgs , workDir , env ) ; try { shExec . execute ( ) ; } catch ( Exception e )... | Helper method that runs a LinuxTaskController command |
32,450 | private String getJobId ( TaskControllerContext context ) { String taskId = context . task . getTaskID ( ) . toString ( ) ; TaskAttemptID tId = TaskAttemptID . forName ( taskId ) ; String jobId = tId . getJobID ( ) . toString ( ) ; return jobId ; } | get the Job ID from the information in the TaskControllerContext |
32,451 | private String getDirectoryChosenForTask ( File directory , TaskControllerContext context ) { String jobId = getJobId ( context ) ; String taskId = context . task . getTaskID ( ) . toString ( ) ; for ( String dir : mapredLocalDirs ) { File mapredDir = new File ( dir ) ; File taskDir = new File ( mapredDir , TaskTracker... | this task . |
32,452 | private void setupTaskLogFileAccess ( TaskControllerContext context ) { TaskAttemptID taskId = context . task . getTaskID ( ) ; File f = TaskLog . getTaskLogFile ( taskId , TaskLog . LogName . SYSLOG ) ; String taskAttemptLogDir = f . getParentFile ( ) . getAbsolutePath ( ) ; changeDirectoryPermissions ( taskAttemptLog... | the task log directory |
32,453 | private void setupTaskCacheFileAccess ( TaskControllerContext context ) { String taskId = context . task . getTaskID ( ) . toString ( ) ; JobID jobId = JobID . forName ( getJobId ( context ) ) ; for ( String localDir : mapredLocalDirs ) { File f = new File ( localDir ) ; File taskCacheDir = new File ( f , TaskTracker .... | the files under the job and task cache directories |
32,454 | private void changeDirectoryPermissions ( String dir , String mode , boolean isRecursive ) { int ret = 0 ; try { ret = FileUtil . chmod ( dir , mode , isRecursive ) ; } catch ( Exception e ) { LOG . warn ( "Exception in changing permissions for directory " + dir + ". Exception: " + e . getMessage ( ) ) ; } if ( ret != ... | convenience method to execute chmod . |
32,455 | private String getTaskCacheDirectory ( TaskControllerContext context ) { String taskId = context . task . getTaskID ( ) . toString ( ) ; File cacheDirForJob = context . env . workDir . getParentFile ( ) . getParentFile ( ) ; if ( context . task . isTaskCleanupTask ( ) ) { taskId = taskId + TaskTracker . TASK_CLEANUP_SU... | Return the task specific directory under the cache . |
32,456 | private void writeCommand ( String cmdLine , String directory ) throws IOException { PrintWriter pw = null ; String commandFile = directory + File . separator + COMMAND_FILE ; LOG . info ( "Writing commands to " + commandFile ) ; try { FileWriter fw = new FileWriter ( commandFile ) ; BufferedWriter bw = new BufferedWri... | a file and execute it . |
32,457 | private void finishTask ( TaskControllerContext context , TaskCommands command ) throws IOException { if ( context . task == null ) { LOG . info ( "Context task null not killing the JVM" ) ; return ; } ShellCommandExecutor shExec = buildTaskControllerExecutor ( command , context . env . conf . getUser ( ) , buildKillTa... | Convenience method used to sending appropriate Kill signal to the task VM |
32,458 | public static String getHistoryFilePath ( JobID jobId ) { MovedFileInfo info = jobHistoryFileMap . get ( jobId ) ; if ( info == null ) { return null ; } return info . historyFile ; } | Given the job id return the history file path from the cache |
32,459 | public static boolean init ( JobHistoryObserver jobTracker , JobConf conf , String hostname , long jobTrackerStartTime ) { try { LOG_DIR = conf . get ( "hadoop.job.history.location" , "file:///" + new File ( System . getProperty ( "hadoop.log.dir" , "/tmp" ) ) . getAbsolutePath ( ) + File . separator + "history" ) ; JO... | Initialize JobHistory files . |
32,460 | private static void parseLine ( String line , Listener l , boolean isEscaped ) throws IOException { int idx = line . indexOf ( ' ' ) ; String recType = line . substring ( 0 , idx ) ; String data = line . substring ( idx + 1 , line . length ( ) ) ; Matcher matcher = pattern . matcher ( data ) ; Map < Keys , String > par... | Parse a single line of history . |
32,461 | public static void log ( PrintWriter out , RecordTypes recordType , Keys key , String value ) { value = escapeString ( value ) ; out . println ( recordType . name ( ) + DELIMITER + key + "=\"" + value + "\"" + DELIMITER + LINE_DELIMITER_CHAR ) ; } | Log a raw record type with keys and values . This is method is generally not used directly . |
32,462 | public static String getTaskLogsUrl ( JobHistory . TaskAttempt attempt ) { if ( attempt . get ( Keys . HTTP_PORT ) . equals ( "" ) || attempt . get ( Keys . TRACKER_NAME ) . equals ( "" ) || attempt . get ( Keys . TASK_ATTEMPT_ID ) . equals ( "" ) ) { return null ; } String taskTrackerName = JobInProgress . convertTrac... | Return the TaskLogsUrl of a particular TaskAttempt |
32,463 | public int getAvailableSlots ( TaskType taskType ) { int availableSlots = 0 ; if ( taskType == TaskType . MAP ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( trackerName + " getAvailSlots:" + " max(m)=" + status . getMaxMapSlots ( ) + " occupied(m)=" + status . countOccupiedMapSlots ( ) ) ; } availableSlots = statu... | Get the number of currently available slots on this tasktracker for the given type of the task . |
32,464 | private void sendIncrementalBlockReport ( long startTime ) throws Exception { Block [ ] receivedAndDeletedBlockArray = null ; int numBlocksReceivedAndDeleted = 0 ; int currentPendingRequests = 0 ; synchronized ( receivedAndDeletedBlockList ) { lastDeletedReport = startTime ; numBlocksReceivedAndDeleted = receivedAndDel... | Sends an incremental block report to the Namenode . |
32,465 | private boolean shouldSendIncrementalReport ( long startTime ) { boolean isPrimary = isPrimaryServiceCached ( ) || donotDelayIncrementalBlockReports ; boolean deleteIntervalTrigger = ( startTime - lastDeletedReport > anode . deletedReportInterval ) ; boolean sendReportDefault = pendingReceivedRequests > 0 || deleteInte... | Checks if an incremental block report should be sent . |
32,466 | private void processFailedBlocks ( Block [ ] failed , int failedPendingRequests ) { synchronized ( receivedAndDeletedBlockList ) { for ( int i = failed . length - 1 ; i >= 0 ; i -- ) { receivedAndDeletedBlockList . add ( 0 , failed [ i ] ) ; } pendingReceivedRequests += failedPendingRequests ; } } | Adds blocks of incremental block report back to the receivedAndDeletedBlockList when handling an exception |
32,467 | private boolean checkFailover ( ) throws InterruptedException { boolean isPrimary = isPrimaryServiceCached ( ) ; if ( ! isPrimary && isPrimaryService ( ) ) { this . servicePair . setPrimaryOfferService ( this ) ; return true ; } return false ; } | Determines whether a failover has happened and accordingly takes the appropriate action . |
32,468 | private boolean processCommand ( DatanodeCommand [ ] cmds , long processStartTime ) throws InterruptedException { if ( cmds != null ) { boolean switchedFromStandbyToPrimary = checkFailover ( ) ; for ( DatanodeCommand cmd : cmds ) { try { if ( switchedFromStandbyToPrimary && cmd . getAction ( ) == DatanodeProtocol . DNA... | Process an array of datanode commands . This function has logic to check for failover . Any commands should be processed using this function as an entry point . |
32,469 | private void prepareFailover ( ) { LOG . info ( "PREPARE FAILOVER requested by : " + this . avatarnodeAddress ) ; setBackoff ( false ) ; this . donotDelayIncrementalBlockReports = true ; InjectionHandler . processEvent ( InjectionEvent . OFFERSERVICE_PREPARE_FAILOVER , nsRegistration . toString ( ) ) ; } | Take actions in preparation for failover . |
32,470 | private boolean clearPrimary ( ) throws InterruptedException { try { if ( ! isPrimaryServiceCached ( ) ) { InetSocketAddress addr1 = servicePair . avatarAddr1 ; InetSocketAddress addr2 = servicePair . avatarAddr2 ; if ( avatarnodeAddress . equals ( addr2 ) ) { LOG . info ( "Restarting service for AvatarNode : " + addr1... | This is clears up the thread heartbeating to the primary Avatar by restarting it . This makes sure all commands from the primary have been processed by the datanode . This method is used during failover . |
32,471 | public void scheduleBlockReport ( long delay ) { if ( delay > 0 ) { lastBlockReport = System . currentTimeMillis ( ) - ( anode . blockReportInterval - R . nextInt ( ( int ) ( delay ) ) ) ; } else { lastBlockReport = lastHeartbeat - anode . blockReportInterval ; } resetBlockReportTime = true ; } | This methods arranges for the data node to send the block report at the next heartbeat . |
32,472 | void removeReceivedBlocks ( Block [ ] removeList ) { long start = AvatarDataNode . now ( ) ; synchronized ( receivedAndDeletedBlockList ) { ReceivedBlockInfo block = new ReceivedBlockInfo ( ) ; block . setDelHints ( ReceivedBlockInfo . WILDCARD_HINT ) ; for ( Block bi : removeList ) { block . set ( bi . getBlockId ( ) ... | Remove blocks from blockReceived queues |
32,473 | static int transform ( int crc , int [ ] [ ] lookupTable ) { int cb1 = lookupTable [ 0 ] [ crc & 0xff ] ; int cb2 = lookupTable [ 1 ] [ ( crc >>>= 8 ) & 0xff ] ; int cb3 = lookupTable [ 2 ] [ ( crc >>>= 8 ) & 0xff ] ; int cb4 = lookupTable [ 3 ] [ ( crc >>>= 8 ) & 0xff ] ; return cb1 ^ cb2 ^ cb3 ^ cb4 ; } | Helper function to transform a CRC using lookup table . Currently it is used for calculating CRC after adding bytes zeros to source byte array . The special lookup table needs to be passed in for this specific transformation |
32,474 | static public int concatCrc ( int crc1 , int crc2 , int order ) { int crcForCrc1 = crc1 ; int orderRemained = order ; for ( LookupTable lookupTable : lookupTables ) { while ( orderRemained >= lookupTable . getOrder ( ) ) { crcForCrc1 = transform ( crcForCrc1 , lookupTable . getLookupTable ( ) ) ; orderRemained -= looku... | Concatenate two CRCs |
32,475 | public static void localRunnerNotification ( JobConf conf , JobStatus status ) { JobEndStatusInfo notification = createNotification ( conf , status ) ; if ( notification != null ) { while ( notification . configureForRetry ( ) ) { try { int code = httpNotification ( notification . getUri ( ) ) ; if ( code != 200 ) { th... | simple synchronous way |
32,476 | public static boolean canBePreempted ( ResourceType type ) { switch ( type ) { case MAP : return true ; case REDUCE : return true ; case JOBTRACKER : return false ; default : throw new RuntimeException ( "Undefined Preemption behavior for " + type ) ; } } | Tells if preemption is allowed for a resource type . |
32,477 | public static List < LocalityLevel > neededLocalityLevels ( ResourceType type ) { List < LocalityLevel > l = new ArrayList < LocalityLevel > ( ) ; switch ( type ) { case MAP : l . add ( LocalityLevel . NODE ) ; l . add ( LocalityLevel . RACK ) ; l . add ( LocalityLevel . ANY ) ; break ; case REDUCE : l . add ( Locality... | Returns the required locality levels in order of preference for the resource type . |
32,478 | private int findImageVersion ( DataInputStream in ) throws IOException { in . mark ( 42 ) ; int version = in . readInt ( ) ; in . reset ( ) ; return version ; } | Check an fsimage datainputstream s version number . |
32,479 | public static void setBadHostsAndRacks ( Set < String > racks , Set < String > hosts ) { badRacks = racks ; badHosts = hosts ; } | A function to be used by unit tests only |
32,480 | private void initParityConfigs ( ) { Set < String > acceptedCodecIds = new HashSet < String > ( ) ; for ( String s : conf . get ( "dfs.f4.accepted.codecs" , "rs,xor" ) . split ( "," ) ) { acceptedCodecIds . add ( s ) ; } for ( Codec c : Codec . getCodecs ( ) ) { if ( acceptedCodecIds . contains ( c . id ) ) { FSNamesys... | This function initializes configuration for the supported parities . |
32,481 | private HashMap < String , HashSet < Node > > getRackToHostsMapForStripe ( String srcFileName , String parityFileName , int stripeLen , int parityLen , int stripeIndex ) throws IOException { HashMap < String , HashSet < Node > > rackToHosts = new HashMap < String , HashSet < Node > > ( ) ; if ( srcFileName != null ) { ... | reside and the hosts within those racks that host those blocks |
32,482 | private boolean getGoodNode ( HashMap < String , HashSet < Node > > candidateNodesByRacks , boolean considerLoad , long blockSize , List < DatanodeDescriptor > results ) { List < Map . Entry < String , HashSet < Node > > > sorted = new ArrayList < Map . Entry < String , HashSet < Node > > > ( ) ; for ( Map . Entry < St... | Helper function to choose less occupied racks first . |
32,483 | private boolean getGoodNode ( Set < Node > candidateNodes , boolean considerLoad , long blockSize , List < DatanodeDescriptor > results ) { List < DatanodeDescriptor > sorted = new ArrayList < DatanodeDescriptor > ( ) ; for ( Node n : candidateNodes ) { sorted . add ( ( DatanodeDescriptor ) n ) ; } final long blocksize... | Helper function to find a good node . Returns true if found . |
32,484 | private static String checkImageStorage ( URI sharedImage , URI sharedEdits ) { if ( sharedImage . getScheme ( ) . equals ( NNStorage . LOCAL_URI_SCHEME ) ) { return "" ; } else if ( sharedImage . getScheme ( ) . equals ( QuorumJournalManager . QJM_URI_SCHEME ) && sharedImage . equals ( sharedEdits ) ) { return "" ; } ... | Shared image needs to be in file storage or QJM providing that QJM also stores edits . |
32,485 | private static String checkFileURIScheme ( Collection < URI > uris ) { for ( URI uri : uris ) if ( uri . getScheme ( ) . compareTo ( JournalType . FILE . name ( ) . toLowerCase ( ) ) != 0 ) return "The specified path is not a file." + "Avatar supports file non-shared storage only... " ; return "" ; } | For non - shared storage we enforce file uris |
32,486 | public OutputStream getCheckpointOutputStream ( long imageTxId ) throws IOException { String fileName = NNStorage . getCheckpointImageFileName ( imageTxId ) ; return new FileOutputStream ( new File ( sd . getCurrentDir ( ) , fileName ) ) ; } | Get file output stream |
32,487 | private static void renameCheckpointInDir ( StorageDirectory sd , long txid ) throws IOException { File ckpt = NNStorage . getStorageFile ( sd , NameNodeFile . IMAGE_NEW , txid ) ; File curFile = NNStorage . getStorageFile ( sd , NameNodeFile . IMAGE , txid ) ; LOG . info ( "Renaming " + ckpt . getAbsolutePath ( ) + "... | Rolls checkpointed image . |
32,488 | private void reportError ( StorageDirectory sd ) { if ( storage instanceof NNStorage ) { ( ( NNStorage ) storage ) . reportErrorsOnDirectory ( sd , null ) ; } else { LOG . error ( "Failed direcory: " + sd . getCurrentDir ( ) ) ; } } | Reports error to underlying storage . |
32,489 | public ResourceMetadata getResourceMetadata ( ) { if ( poolInfo . getPoolName ( ) == null || ! counters . containsKey ( MetricName . MIN ) || ! counters . containsKey ( MetricName . MAX ) || ! counters . containsKey ( MetricName . GRANTED ) || ! counters . containsKey ( MetricName . REQUESTED ) ) { return null ; } retu... | Get a snapshot of the resource metadata for this pool . Used for collecting metrics . Will not collect resource metadata for PoolGroup objects or if any counters are missing . |
32,490 | public void updateMetricsRecord ( ) { for ( Map . Entry < MetricName , Long > entry : counters . entrySet ( ) ) { String name = ( entry . getKey ( ) + "_" + type ) . toLowerCase ( ) ; record . setMetric ( name , entry . getValue ( ) ) ; } record . update ( ) ; } | Update the metrics record associated with this object . |
32,491 | public void configure ( JobConf jobConf ) { String prefix = getPrefix ( isMap ) ; chainJobConf = jobConf ; SerializationFactory serializationFactory = new SerializationFactory ( chainJobConf ) ; int index = jobConf . getInt ( prefix + CHAIN_MAPPER_SIZE , 0 ) ; for ( int i = 0 ; i < index ; i ++ ) { Class < ? extends Ma... | Configures all the chain elements for the task . |
32,492 | public void close ( ) throws IOException { for ( Mapper map : mappers ) { map . close ( ) ; } if ( reducer != null ) { reducer . close ( ) ; } } | Closes all the chain elements . |
32,493 | public void fsck ( ) throws IOException { InjectionHandler . processEvent ( InjectionEvent . NAMENODE_FSCK_START ) ; try { FileStatus [ ] files = nn . namesystem . dir . getListing ( path ) ; FsckResult res = new FsckResult ( ) ; if ( ! this . showFiles && ! this . showBlocks && ! this . showLocations && ! this . showR... | Check files on DFS starting from the indicated path . |
32,494 | public String getPrettyReport ( JobID jobId ) { Map < TaskAttemptID , TaskLaunch > lastLaunch = new HashMap < TaskAttemptID , CoronaStateUpdate . TaskLaunch > ( ) ; Map < TaskAttemptID , TaskStatus . State > lastKnownStatus = new HashMap < TaskAttemptID , TaskStatus . State > ( ) ; JTFailoverMetrics jtFailoverMetrics =... | Creates pretty report of saved state |
32,495 | protected static String [ ] getFileSystemCounterNames ( String uriScheme ) { String scheme = uriScheme . toUpperCase ( ) ; return new String [ ] { scheme + "_BYTES_READ" , scheme + "_BYTES_WRITTEN" , scheme + "_FILES_CREATED" , scheme + "_BYTES_READ_LOCAL" , scheme + "_BYTES_READ_RACK" , scheme + "_READ_EXCEPTIONS" , s... | Counters to measure the usage of the different file systems . Always return the String array with two elements . First one is the name of BYTES_READ counter and second one is of the BYTES_WRITTEN counter . |
32,496 | protected void reportNextRecordRange ( final TaskUmbilicalProtocol umbilical , long nextRecIndex ) throws IOException { long len = nextRecIndex - currentRecStartIndex + 1 ; SortedRanges . Range range = new SortedRanges . Range ( currentRecStartIndex , len ) ; taskStatus . setNextRecordRange ( range ) ; LOG . debug ( "s... | Reports the next executing record range to TaskTracker . |
32,497 | void updateGCcounters ( ) { long gccount = 0 ; long gctime = 0 ; for ( GarbageCollectorMXBean gc : ManagementFactory . getGarbageCollectorMXBeans ( ) ) { long count = gc . getCollectionCount ( ) ; if ( count >= 0 ) { gccount += count ; } long time = gc . getCollectionTime ( ) ; if ( time >= 0 ) { gctime += time ; } } I... | Update counters about Garbage Collection |
32,498 | void updateResourceCounters ( ) { if ( resourceCalculator == null ) { return ; } ProcResourceValues res = resourceCalculator . getProcResourceValues ( ) ; long cpuTime = res . getCumulativeCpuTime ( ) ; long pMem = res . getPhysicalMemorySize ( ) ; long vMem = res . getVirtualMemorySize ( ) ; long cpuJvmTime = this . j... | Update resource information counters |
32,499 | public static void loadStaticResolutions ( Configuration conf ) { String hostToResolved [ ] = conf . getStrings ( "hadoop.net.static.resolutions" ) ; if ( hostToResolved != null ) { for ( String str : hostToResolved ) { String name = str . substring ( 0 , str . indexOf ( '=' ) ) ; String resolvedName = str . substring ... | Load the static resolutions from configuration . This is required for junit to work on testcases that simulate multiple nodes on a single physical node . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.