idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
40,800
private boolean checkParameterSet ( HttpServletResponse resp , String parameter , String parameterName ) throws IOException { if ( parameter == null ) { showErrorPage ( resp , "The parameter '" + parameterName + "' is not set." ) ; return true ; } else { return false ; } }
Checks the given parameter . If it is null it prints the error page .
40,801
private void cancelOrKillExecution ( boolean cancel ) { final Thread executingThread = this . environment . getExecutingThread ( ) ; if ( executingThread == null ) { return ; } if ( this . executionState != ExecutionState . RUNNING && this . executionState != ExecutionState . FINISHING ) { return ; } LOG . info ( ( cancel ? "Canceling " : "Killing " ) + this . environment . getTaskNameWithIndex ( ) ) ; if ( cancel ) { this . isCanceled = true ; executionStateChanged ( ExecutionState . CANCELING , null ) ; try { final AbstractInvokable invokable = this . environment . getInvokable ( ) ; if ( invokable != null ) { invokable . cancel ( ) ; } } catch ( Throwable e ) { LOG . error ( StringUtils . stringifyException ( e ) ) ; } } while ( true ) { executingThread . interrupt ( ) ; if ( ! executingThread . isAlive ( ) ) { break ; } try { executingThread . join ( 1000 ) ; } catch ( InterruptedException e ) { } if ( ! executingThread . isAlive ( ) ) { break ; } if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Sending repeated " + ( cancel == true ? "canceling" : "killing" ) + " signal to " + this . environment . getTaskName ( ) + " with state " + this . executionState ) ; } } }
Cancels or kills the task .
40,802
public boolean hasNext ( ) throws IOException , InterruptedException { if ( this . lookahead != null ) { return true ; } else { if ( this . noMoreRecordsWillFollow ) { return false ; } T record = instantiateRecordType ( ) ; while ( true ) { InputChannelResult result = this . inputGate . readRecord ( record ) ; switch ( result ) { case INTERMEDIATE_RECORD_FROM_BUFFER : case LAST_RECORD_FROM_BUFFER : this . lookahead = record ; return true ; case END_OF_SUPERSTEP : if ( incrementEndOfSuperstepEventAndCheck ( ) ) { return false ; } else { break ; } case TASK_EVENT : handleEvent ( this . inputGate . getCurrentEvent ( ) ) ; break ; case END_OF_STREAM : this . noMoreRecordsWillFollow = true ; return false ; default : ; } } } }
Checks if at least one more record can be read from the associated input gate . This method may block until the associated input gate is able to read the record from one of its input channels .
40,803
private final void checkAndCreateDirectories ( File f , boolean needWritePermission ) throws IOException { String dir = f . getAbsolutePath ( ) ; if ( f . exists ( ) && ! f . isDirectory ( ) ) { throw new IOException ( "A none directory file with the same name as the configured directory '" + dir + "' already exists." ) ; } if ( ! f . exists ( ) ) { if ( ! f . mkdirs ( ) ) { throw new IOException ( "Could not create the directory '" + dir + "'." ) ; } } if ( ! ( f . canRead ( ) && f . canExecute ( ) ) ) { throw new IOException ( "The directory '" + dir + "' cannot be read and listed." ) ; } if ( needWritePermission && ! f . canWrite ( ) ) { throw new IOException ( "No write access could be obtained on directory '" + dir + "'." ) ; } }
Checks and creates the directory described by the abstract directory path . This function checks if the directory exists and creates it if necessary . It also checks read permissions and write permission if necessary .
40,804
public O withConstantSet ( String ... constantSet ) { SingleInputSemanticProperties props = SemanticPropUtil . getSemanticPropsSingleFromString ( constantSet , null , null , this . getInputType ( ) , this . getResultType ( ) ) ; this . setSemanticProperties ( props ) ; @ SuppressWarnings ( "unchecked" ) O returnType = ( O ) this ; return returnType ; }
Adds a constant - set annotation for the UDF .
40,805
private void fillReadBuffer ( ) throws IOException { if ( splitLength == FileInputFormat . READ_WHOLE_SPLIT_FLAG ) { int read = this . stream . read ( this . readBuffer , 0 , this . readBufferSize ) ; if ( read == - 1 ) { exhausted = true ; } else { this . streamPos += read ; this . readBufferPos = 0 ; this . readBufferLimit = read ; } return ; } int toRead = ( int ) Math . min ( this . streamEnd - this . streamPos , this . readBufferSize ) ; if ( toRead <= 0 ) { this . exhausted = true ; return ; } int read = this . stream . read ( this . readBuffer , 0 , toRead ) ; if ( read <= 0 ) { this . exhausted = true ; } else { this . streamPos += read ; this . readBufferPos = 0 ; this . readBufferLimit = read ; } }
Fills the next read buffer from the file stream .
40,806
public static Set < Annotation > readSingleConstantAnnotations ( Class < ? > udfClass ) { ConstantFields constantSet = udfClass . getAnnotation ( ConstantFields . class ) ; ConstantFieldsExcept notConstantSet = udfClass . getAnnotation ( ConstantFieldsExcept . class ) ; ReadFields readfieldSet = udfClass . getAnnotation ( ReadFields . class ) ; Set < Annotation > result = null ; if ( notConstantSet != null && constantSet != null ) { throw new InvalidProgramException ( "Either " + ConstantFields . class . getSimpleName ( ) + " or " + ConstantFieldsExcept . class . getSimpleName ( ) + " can be annotated to a function, not both." ) ; } if ( notConstantSet != null ) { result = new HashSet < Annotation > ( ) ; result . add ( notConstantSet ) ; } if ( constantSet != null ) { result = new HashSet < Annotation > ( ) ; result . add ( constantSet ) ; } if ( readfieldSet != null ) { if ( result == null ) { result = new HashSet < Annotation > ( ) ; } result . add ( readfieldSet ) ; } return result ; }
Reads the annotations of a user defined function with one input and returns semantic properties according to the constant fields annotated .
40,807
public static Set < Annotation > readDualConstantAnnotations ( Class < ? > udfClass ) { ConstantFieldsFirst constantSet1 = udfClass . getAnnotation ( ConstantFieldsFirst . class ) ; ConstantFieldsSecond constantSet2 = udfClass . getAnnotation ( ConstantFieldsSecond . class ) ; ConstantFieldsFirstExcept notConstantSet1 = udfClass . getAnnotation ( ConstantFieldsFirstExcept . class ) ; ConstantFieldsSecondExcept notConstantSet2 = udfClass . getAnnotation ( ConstantFieldsSecondExcept . class ) ; ReadFieldsFirst readfieldSet1 = udfClass . getAnnotation ( ReadFieldsFirst . class ) ; ReadFieldsSecond readfieldSet2 = udfClass . getAnnotation ( ReadFieldsSecond . class ) ; if ( notConstantSet1 != null && constantSet1 != null ) { throw new InvalidProgramException ( "Either " + ConstantFieldsFirst . class . getSimpleName ( ) + " or " + ConstantFieldsFirstExcept . class . getSimpleName ( ) + " can be annotated to a function, not both." ) ; } if ( constantSet2 != null && notConstantSet2 != null ) { throw new InvalidProgramException ( "Either " + ConstantFieldsSecond . class . getSimpleName ( ) + " or " + ConstantFieldsSecondExcept . class . getSimpleName ( ) + " can be annotated to a function, not both." ) ; } Set < Annotation > result = null ; if ( notConstantSet2 != null ) { result = new HashSet < Annotation > ( ) ; result . add ( notConstantSet2 ) ; } if ( constantSet2 != null ) { result = new HashSet < Annotation > ( ) ; result . add ( constantSet2 ) ; } if ( readfieldSet2 != null ) { if ( result == null ) { result = new HashSet < Annotation > ( ) ; } result . add ( readfieldSet2 ) ; } if ( notConstantSet1 != null ) { if ( result == null ) { result = new HashSet < Annotation > ( ) ; } result . add ( notConstantSet1 ) ; } if ( constantSet1 != null ) { if ( result == null ) { result = new HashSet < Annotation > ( ) ; } result . add ( constantSet1 ) ; } if ( readfieldSet1 != null ) { if ( result == null ) { result = new HashSet < Annotation > ( ) ; } result . add ( readfieldSet1 ) ; } return result ; }
Reads the annotations of a user defined function with two inputs and returns semantic properties according to the constant fields annotated .
40,808
public final CheckedMemorySegment put ( int index , byte b ) { if ( index >= 0 && index < this . size ) { this . memory [ this . offset + index ] = b ; return this ; } else { throw new IndexOutOfBoundsException ( ) ; } }
Writes the given byte into this buffer at the given position .
40,809
public final CheckedMemorySegment get ( int index , byte [ ] dst , int offset , int length ) { if ( index >= 0 && index < this . size && index <= this . size - length && offset <= dst . length - length ) { System . arraycopy ( this . memory , this . offset + index , dst , offset , length ) ; return this ; } else { throw new IndexOutOfBoundsException ( ) ; } }
Bulk get method . Copies length memory from the specified position to the destination memory beginning at the given offset
40,810
public final CheckedMemorySegment put ( int index , byte [ ] src , int offset , int length ) { if ( index >= 0 && index < this . size && index <= this . size - length && offset <= src . length - length ) { System . arraycopy ( src , offset , this . memory , this . offset + index , length ) ; return this ; } else { throw new IndexOutOfBoundsException ( ) ; } }
Bulk put method . Copies length memory starting at position offset from the source memory into the memory segment starting at the specified index .
40,811
public final CheckedMemorySegment putBoolean ( int index , boolean value ) { if ( index >= 0 && index < this . size ) { this . memory [ this . offset + index ] = ( byte ) ( value ? 1 : 0 ) ; return this ; } else { throw new IndexOutOfBoundsException ( ) ; } }
Writes one byte containing the byte value into this buffer at the given position .
40,812
public final char getChar ( int index ) { if ( index >= 0 && index < this . size - 1 ) { return ( char ) ( ( ( this . memory [ this . offset + index + 0 ] & 0xff ) << 8 ) | ( this . memory [ this . offset + index + 1 ] & 0xff ) ) ; } else { throw new IndexOutOfBoundsException ( ) ; } }
Reads two memory at the given position composing them into a char value according to the current byte order .
40,813
public final CheckedMemorySegment putChar ( int index , char value ) { if ( index >= 0 && index < this . size - 1 ) { this . memory [ this . offset + index + 0 ] = ( byte ) ( value >> 8 ) ; this . memory [ this . offset + index + 1 ] = ( byte ) value ; return this ; } else { throw new IndexOutOfBoundsException ( ) ; } }
Writes two memory containing the given char value in the current byte order into this buffer at the given position .
40,814
public final short getShort ( int index ) { if ( index >= 0 && index < this . size - 1 ) { return ( short ) ( ( ( this . memory [ this . offset + index + 0 ] & 0xff ) << 8 ) | ( ( this . memory [ this . offset + index + 1 ] & 0xff ) ) ) ; } else { throw new IndexOutOfBoundsException ( ) ; } }
Reads two memory at the given position composing them into a short value according to the current byte order .
40,815
public final CheckedMemorySegment putShort ( int index , short value ) { if ( index >= 0 && index < this . size - 1 ) { this . memory [ this . offset + index + 0 ] = ( byte ) ( value >> 8 ) ; this . memory [ this . offset + index + 1 ] = ( byte ) value ; return this ; } else { throw new IndexOutOfBoundsException ( ) ; } }
Writes two memory containing the given short value in the current byte order into this buffer at the given position .
40,816
private void sortAvailableInstancesByNumberOfCPUCores ( ) { if ( this . availableInstanceTypes . length < 2 ) { return ; } for ( int i = 1 ; i < this . availableInstanceTypes . length ; i ++ ) { final InstanceType it = this . availableInstanceTypes [ i ] ; int j = i ; while ( j > 0 && this . availableInstanceTypes [ j - 1 ] . getNumberOfCores ( ) < it . getNumberOfCores ( ) ) { this . availableInstanceTypes [ j ] = this . availableInstanceTypes [ j - 1 ] ; -- j ; } this . availableInstanceTypes [ j ] = it ; } }
Sorts the list of available instance types by the number of CPU cores in a descending order .
40,817
private void checkPendingRequests ( ) { final Iterator < Map . Entry < JobID , PendingRequestsMap > > it = this . pendingRequestsOfJob . entrySet ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { final List < AllocatedResource > allocatedResources = new ArrayList < AllocatedResource > ( ) ; final Map . Entry < JobID , PendingRequestsMap > entry = it . next ( ) ; final JobID jobID = entry . getKey ( ) ; final PendingRequestsMap pendingRequestsMap = entry . getValue ( ) ; final Iterator < Map . Entry < InstanceType , Integer > > it2 = pendingRequestsMap . iterator ( ) ; while ( it2 . hasNext ( ) ) { final Map . Entry < InstanceType , Integer > entry2 = it2 . next ( ) ; final InstanceType requestedInstanceType = entry2 . getKey ( ) ; int numberOfPendingInstances = entry2 . getValue ( ) . intValue ( ) ; if ( numberOfPendingInstances <= 0 ) { LOG . error ( "Inconsistency: Job " + jobID + " has " + numberOfPendingInstances + " requests for instance type " + requestedInstanceType . getIdentifier ( ) ) ; continue ; } while ( numberOfPendingInstances > 0 ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Trying to allocate instance of type " + requestedInstanceType . getIdentifier ( ) ) ; } final AllocatedSlice slice = getSliceOfType ( jobID , requestedInstanceType ) ; if ( slice == null ) { break ; } else { LOG . info ( "Allocated instance of type " + requestedInstanceType . getIdentifier ( ) + " as a result of pending request for job " + jobID ) ; -- numberOfPendingInstances ; pendingRequestsMap . decreaseNumberOfPendingInstances ( requestedInstanceType ) ; List < AllocatedSlice > allocatedSlices = this . slicesOfJobs . get ( jobID ) ; if ( allocatedSlices == null ) { allocatedSlices = new ArrayList < AllocatedSlice > ( ) ; this . slicesOfJobs . put ( jobID , allocatedSlices ) ; } allocatedSlices . add ( slice ) ; allocatedResources . add ( new AllocatedResource ( slice . getHostingInstance ( ) , slice . getType ( ) , slice . getAllocationID ( ) ) ) ; } } } if ( ! allocatedResources . isEmpty ( ) && this . instanceListener != null ) { final ClusterInstanceNotifier clusterInstanceNotifier = new ClusterInstanceNotifier ( this . instanceListener , jobID , allocatedResources ) ; clusterInstanceNotifier . start ( ) ; } } }
Checks if a pending request can be fulfilled .
40,818
private AllocatedSlice getSliceOfType ( final JobID jobID , final InstanceType instanceType ) { AllocatedSlice slice = null ; for ( final ClusterInstance host : this . registeredHosts . values ( ) ) { if ( host . getType ( ) . equals ( instanceType ) ) { slice = host . createSlice ( instanceType , jobID ) ; if ( slice != null ) { break ; } } } if ( slice == null ) { for ( final ClusterInstance host : this . registeredHosts . values ( ) ) { slice = host . createSlice ( instanceType , jobID ) ; if ( slice != null ) { break ; } } } return slice ; }
Attempts to allocate a slice of the given type for the given job . The method first attempts to allocate this slice by finding a physical host which exactly matches the given instance type . If this attempt failed it tries to allocate the slice by partitioning the resources of a more powerful host .
40,819
private int [ ] [ ] calculateInstanceAccommodationMatrix ( ) { if ( this . availableInstanceTypes == null ) { LOG . error ( "Cannot compute instance accommodation matrix: availableInstanceTypes is null" ) ; return null ; } final int matrixSize = this . availableInstanceTypes . length ; final int [ ] [ ] am = new int [ matrixSize ] [ matrixSize ] ; for ( int i = 0 ; i < matrixSize ; i ++ ) { for ( int j = 0 ; j < matrixSize ; j ++ ) { if ( i == j ) { am [ i ] [ j ] = 1 ; } else { final InstanceType sourceType = this . availableInstanceTypes [ i ] ; InstanceType targetType = this . availableInstanceTypes [ j ] ; final int cores = targetType . getNumberOfCores ( ) / sourceType . getNumberOfCores ( ) ; final int cu = targetType . getNumberOfComputeUnits ( ) / sourceType . getNumberOfComputeUnits ( ) ; final int mem = targetType . getMemorySize ( ) / sourceType . getMemorySize ( ) ; final int disk = targetType . getDiskCapacity ( ) / sourceType . getDiskCapacity ( ) ; am [ i ] [ j ] = Math . min ( cores , Math . min ( cu , Math . min ( mem , disk ) ) ) ; } } } return am ; }
Calculates the instance accommodation matrix which stores how many times a particular instance type can be accommodated inside another instance type based on the list of available instance types .
40,820
public void stop ( ) throws Exception { synchronized ( this . lock ) { if ( this . nephele != null ) { this . nephele . stop ( ) ; this . nephele = null ; } else { throw new IllegalStateException ( "The local executor was not started." ) ; } } }
Stop the local executor instance . You should not call executePlan after this .
40,821
public JobExecutionResult executePlan ( Plan plan ) throws Exception { if ( plan == null ) { throw new IllegalArgumentException ( "The plan may not be null." ) ; } ContextChecker checker = new ContextChecker ( ) ; checker . check ( plan ) ; synchronized ( this . lock ) { final boolean shutDownAtEnd ; if ( this . nephele == null ) { shutDownAtEnd = true ; start ( ) ; } else { shutDownAtEnd = false ; } try { PactCompiler pc = new PactCompiler ( new DataStatistics ( ) ) ; OptimizedPlan op = pc . compile ( plan ) ; NepheleJobGraphGenerator jgg = new NepheleJobGraphGenerator ( ) ; JobGraph jobGraph = jgg . compileJobGraph ( op ) ; JobClient jobClient = this . nephele . getJobClient ( jobGraph ) ; JobExecutionResult result = jobClient . submitJobAndWait ( ) ; return result ; } finally { if ( shutDownAtEnd ) { stop ( ) ; } } } }
Execute the given plan on the local Nephele instance wait for the job to finish and return the runtime in milliseconds .
40,822
public static JobExecutionResult execute ( Plan plan ) throws Exception { LocalExecutor exec = new LocalExecutor ( ) ; try { exec . start ( ) ; return exec . executePlan ( plan ) ; } finally { exec . stop ( ) ; } }
Executes the program represented by the given Pact plan .
40,823
public static String getPlanAsJSON ( Plan plan ) { PlanJSONDumpGenerator gen = new PlanJSONDumpGenerator ( ) ; List < DataSinkNode > sinks = PactCompiler . createPreOptimizedPlan ( plan ) ; return gen . getPactPlanAsJSON ( sinks ) ; }
Return unoptimized plan as JSON .
40,824
public void register ( Task task ) throws InsufficientResourcesException { ensureBufferAvailability ( task ) ; RuntimeEnvironment environment = task . getRuntimeEnvironment ( ) ; environment . registerGlobalBufferPool ( this . globalBufferPool ) ; if ( this . localBuffersPools . containsKey ( task . getVertexID ( ) ) ) { throw new IllegalStateException ( "Vertex " + task . getVertexID ( ) + " has a previous buffer pool owner" ) ; } for ( OutputGate gate : environment . outputGates ( ) ) { for ( OutputChannel channel : gate . channels ( ) ) { channel . registerEnvelopeDispatcher ( this ) ; switch ( channel . getChannelType ( ) ) { case IN_MEMORY : addReceiverListHint ( channel . getID ( ) , channel . getConnectedId ( ) ) ; break ; case NETWORK : addReceiverListHint ( channel . getConnectedId ( ) , channel . getID ( ) ) ; break ; } this . channels . put ( channel . getID ( ) , channel ) ; } } this . localBuffersPools . put ( task . getVertexID ( ) , environment ) ; for ( InputGate < ? > gate : environment . inputGates ( ) ) { gate . registerGlobalBufferPool ( this . globalBufferPool ) ; for ( int i = 0 ; i < gate . getNumberOfInputChannels ( ) ; i ++ ) { InputChannel < ? extends IOReadableWritable > channel = gate . getInputChannel ( i ) ; channel . registerEnvelopeDispatcher ( this ) ; if ( channel . getChannelType ( ) == ChannelType . IN_MEMORY ) { addReceiverListHint ( channel . getID ( ) , channel . getConnectedId ( ) ) ; } this . channels . put ( channel . getID ( ) , channel ) ; } this . localBuffersPools . put ( gate . getGateID ( ) , gate ) ; } redistributeBuffers ( ) ; }
Registers the given task with the channel manager .
40,825
public void unregister ( ExecutionVertexID vertexId , Task task ) { final Environment environment = task . getEnvironment ( ) ; for ( ChannelID id : environment . getOutputChannelIDs ( ) ) { Channel channel = this . channels . remove ( id ) ; if ( channel != null ) { channel . destroy ( ) ; } this . receiverCache . remove ( channel ) ; } for ( ChannelID id : environment . getInputChannelIDs ( ) ) { Channel channel = this . channels . remove ( id ) ; if ( channel != null ) { channel . destroy ( ) ; } this . receiverCache . remove ( channel ) ; } for ( GateID id : environment . getInputGateIDs ( ) ) { LocalBufferPoolOwner bufferPool = this . localBuffersPools . remove ( id ) ; if ( bufferPool != null ) { bufferPool . clearLocalBufferPool ( ) ; } } LocalBufferPoolOwner bufferPool = this . localBuffersPools . remove ( vertexId ) ; if ( bufferPool != null ) { bufferPool . clearLocalBufferPool ( ) ; } redistributeBuffers ( ) ; }
Unregisters the given task from the channel manager .
40,826
private EnvelopeReceiverList getReceiverList ( JobID jobID , ChannelID sourceChannelID , boolean reportException ) throws IOException { EnvelopeReceiverList receiverList = this . receiverCache . get ( sourceChannelID ) ; if ( receiverList != null ) { return receiverList ; } while ( true ) { ConnectionInfoLookupResponse lookupResponse ; synchronized ( this . channelLookupService ) { lookupResponse = this . channelLookupService . lookupConnectionInfo ( this . connectionInfo , jobID , sourceChannelID ) ; } if ( lookupResponse . receiverReady ( ) ) { receiverList = new EnvelopeReceiverList ( lookupResponse ) ; break ; } else if ( lookupResponse . receiverNotReady ( ) ) { try { Thread . sleep ( 500 ) ; } catch ( InterruptedException e ) { if ( reportException ) { throw new IOException ( "Lookup was interrupted." ) ; } else { return null ; } } } else if ( lookupResponse . isJobAborting ( ) ) { if ( reportException ) { throw new CancelTaskException ( ) ; } else { return null ; } } else if ( lookupResponse . receiverNotFound ( ) ) { if ( reportException ) { throw new IOException ( "Could not find the receiver for Job " + jobID + ", channel with source id " + sourceChannelID ) ; } else { return null ; } } else { throw new IllegalStateException ( "Unrecognized response to channel lookup." ) ; } } this . receiverCache . put ( sourceChannelID , receiverList ) ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( String . format ( "Receiver for %s: %s [%s])" , sourceChannelID , receiverList . hasLocalReceiver ( ) ? receiverList . getLocalReceiver ( ) : receiverList . getRemoteReceiver ( ) , receiverList . hasLocalReceiver ( ) ? "local" : "remote" ) ) ; } return receiverList ; }
Returns the list of receivers for transfer envelopes produced by the channel with the given source channel ID .
40,827
public void invalidateLookupCacheEntries ( Set < ChannelID > channelIDs ) { for ( ChannelID id : channelIDs ) { this . receiverCache . remove ( id ) ; } }
Invalidates the entries identified by the given channel IDs from the receiver lookup cache .
40,828
public static Class < ? extends VersionedProtocol > getProtocolByName ( final String className ) throws ClassNotFoundException { if ( ! className . contains ( "Protocol" ) ) { throw new ClassNotFoundException ( "Only use this method for protocols!" ) ; } return ( Class < ? extends VersionedProtocol > ) Class . forName ( className , true , getClassLoader ( ) ) . asSubclass ( VersionedProtocol . class ) ; }
Searches for a protocol class by its name and attempts to load it .
40,829
@ SuppressWarnings ( "unchecked" ) public static Class < ? extends IOReadableWritable > getRecordByName ( final String className ) throws ClassNotFoundException { return ( Class < ? extends IOReadableWritable > ) Class . forName ( className , true , getClassLoader ( ) ) ; }
Searches for a record class by its name and attempts to load it .
40,830
public static Class < ? extends FileSystem > getFileSystemByName ( final String className ) throws ClassNotFoundException { return Class . forName ( className , true , getClassLoader ( ) ) . asSubclass ( FileSystem . class ) ; }
Searches for a file system class by its name and attempts to load it .
40,831
public void open ( ) { if ( ! this . closed . compareAndSet ( true , false ) ) { throw new IllegalStateException ( "Hash Table cannot be opened, because it is currently not closed." ) ; } final int partitionFanOut = getPartitioningFanOutNoEstimates ( this . availableMemory . size ( ) ) ; createPartitions ( partitionFanOut ) ; final int numBuckets = getInitialTableSize ( this . availableMemory . size ( ) , this . segmentSize , partitionFanOut , this . avgRecordLen ) ; initTable ( numBuckets , ( byte ) partitionFanOut ) ; }
Build the hash table
40,832
protected void mergeBranchPlanMaps ( Map < OptimizerNode , PlanNode > branchPlan1 , Map < OptimizerNode , PlanNode > branchPlan2 ) { }
Merging can only take place after the solutionSetDelta and nextWorkset PlanNode has been set because they can contain also some of the branching nodes .
40,833
public FileInputSplit [ ] createInputSplits ( int minNumSplits ) throws IOException { int numAvroFiles = 0 ; final Path path = this . filePath ; final FileSystem fs = path . getFileSystem ( ) ; final FileStatus pathFile = fs . getFileStatus ( path ) ; if ( ! acceptFile ( pathFile ) ) { throw new IOException ( "The given file does not pass the file-filter" ) ; } if ( pathFile . isDir ( ) ) { final FileStatus [ ] dir = fs . listStatus ( path ) ; for ( int i = 0 ; i < dir . length ; i ++ ) { if ( ! dir [ i ] . isDir ( ) && acceptFile ( dir [ i ] ) ) { numAvroFiles ++ ; } } } else { numAvroFiles = 1 ; } return super . createInputSplits ( numAvroFiles ) ; }
Set minNumSplits to number of files .
40,834
public int getNumberOfInputExecutionVertices ( ) { int retVal = 0 ; final Iterator < ExecutionGroupVertex > it = this . stageMembers . iterator ( ) ; while ( it . hasNext ( ) ) { final ExecutionGroupVertex groupVertex = it . next ( ) ; if ( groupVertex . isInputVertex ( ) ) { retVal += groupVertex . getCurrentNumberOfGroupMembers ( ) ; } } return retVal ; }
Returns the number of input execution vertices in this stage i . e . the number of execution vertices which are connected to vertices in a lower stage or have no input channels .
40,835
public int getNumberOfOutputExecutionVertices ( ) { int retVal = 0 ; final Iterator < ExecutionGroupVertex > it = this . stageMembers . iterator ( ) ; while ( it . hasNext ( ) ) { final ExecutionGroupVertex groupVertex = it . next ( ) ; if ( groupVertex . isOutputVertex ( ) ) { retVal += groupVertex . getCurrentNumberOfGroupMembers ( ) ; } } return retVal ; }
Returns the number of output execution vertices in this stage i . e . the number of execution vertices which are connected to vertices in a higher stage or have no output channels .
40,836
public void collectRequiredInstanceTypes ( final InstanceRequestMap instanceRequestMap , final ExecutionState executionState ) { final Set < AbstractInstance > collectedInstances = new HashSet < AbstractInstance > ( ) ; final ExecutionGroupVertexIterator groupIt = new ExecutionGroupVertexIterator ( this . getExecutionGraph ( ) , true , this . stageNum ) ; while ( groupIt . hasNext ( ) ) { final ExecutionGroupVertex groupVertex = groupIt . next ( ) ; final Iterator < ExecutionVertex > vertexIt = groupVertex . iterator ( ) ; while ( vertexIt . hasNext ( ) ) { final ExecutionVertex vertex = vertexIt . next ( ) ; if ( vertex . getExecutionState ( ) == executionState ) { final AbstractInstance instance = vertex . getAllocatedResource ( ) . getInstance ( ) ; if ( collectedInstances . contains ( instance ) ) { continue ; } else { collectedInstances . add ( instance ) ; } if ( instance instanceof DummyInstance ) { final InstanceType instanceType = instance . getType ( ) ; int num = instanceRequestMap . getMaximumNumberOfInstances ( instanceType ) ; ++ num ; instanceRequestMap . setMaximumNumberOfInstances ( instanceType , num ) ; if ( groupVertex . isInputVertex ( ) ) { num = instanceRequestMap . getMinimumNumberOfInstances ( instanceType ) ; ++ num ; instanceRequestMap . setMinimumNumberOfInstances ( instanceType , num ) ; } } else { LOG . debug ( "Execution Vertex " + vertex . getName ( ) + " (" + vertex . getID ( ) + ") is already assigned to non-dummy instance, skipping..." ) ; } } } } final Iterator < Map . Entry < InstanceType , Integer > > it = instanceRequestMap . getMaximumIterator ( ) ; while ( it . hasNext ( ) ) { final Map . Entry < InstanceType , Integer > entry = it . next ( ) ; if ( instanceRequestMap . getMinimumNumberOfInstances ( entry . getKey ( ) ) == 0 ) { instanceRequestMap . setMinimumNumberOfInstances ( entry . getKey ( ) , entry . getValue ( ) ) ; } } }
Checks which instance types and how many instances of these types are required to execute this stage of the job graph . The required instance types and the number of instances are collected in the given map . Note that this method does not clear the map before collecting the instances .
40,837
void reconstructExecutionPipelines ( ) { Iterator < ExecutionGroupVertex > it = this . stageMembers . iterator ( ) ; final Set < ExecutionVertex > alreadyVisited = new HashSet < ExecutionVertex > ( ) ; while ( it . hasNext ( ) ) { final ExecutionGroupVertex groupVertex = it . next ( ) ; if ( ! groupVertex . isInputVertex ( ) ) { continue ; } final Iterator < ExecutionVertex > vertexIt = groupVertex . iterator ( ) ; while ( vertexIt . hasNext ( ) ) { final ExecutionVertex vertex = vertexIt . next ( ) ; reconstructExecutionPipeline ( vertex , true , alreadyVisited ) ; } } it = this . stageMembers . iterator ( ) ; alreadyVisited . clear ( ) ; while ( it . hasNext ( ) ) { final ExecutionGroupVertex groupVertex = it . next ( ) ; if ( ! groupVertex . isOutputVertex ( ) ) { continue ; } final Iterator < ExecutionVertex > vertexIt = groupVertex . iterator ( ) ; while ( vertexIt . hasNext ( ) ) { final ExecutionVertex vertex = vertexIt . next ( ) ; reconstructExecutionPipeline ( vertex , false , alreadyVisited ) ; } } }
Reconstructs the execution pipelines for this execution stage .
40,838
private void reconstructExecutionPipeline ( final ExecutionVertex vertex , final boolean forward , final Set < ExecutionVertex > alreadyVisited ) { ExecutionPipeline pipeline = vertex . getExecutionPipeline ( ) ; if ( pipeline == null ) { pipeline = new ExecutionPipeline ( ) ; vertex . setExecutionPipeline ( pipeline ) ; } alreadyVisited . add ( vertex ) ; if ( forward ) { final int numberOfOutputGates = vertex . getNumberOfOutputGates ( ) ; for ( int i = 0 ; i < numberOfOutputGates ; ++ i ) { final ExecutionGate outputGate = vertex . getOutputGate ( i ) ; final ChannelType channelType = outputGate . getChannelType ( ) ; final int numberOfOutputChannels = outputGate . getNumberOfEdges ( ) ; for ( int j = 0 ; j < numberOfOutputChannels ; ++ j ) { final ExecutionEdge outputChannel = outputGate . getEdge ( j ) ; final ExecutionVertex connectedVertex = outputChannel . getInputGate ( ) . getVertex ( ) ; boolean recurse = false ; if ( ! alreadyVisited . contains ( connectedVertex ) ) { recurse = true ; } if ( channelType == ChannelType . IN_MEMORY && ! pipeline . equals ( connectedVertex . getExecutionPipeline ( ) ) ) { connectedVertex . setExecutionPipeline ( pipeline ) ; recurse = true ; } if ( recurse ) { reconstructExecutionPipeline ( connectedVertex , true , alreadyVisited ) ; } } } } else { final int numberOfInputGates = vertex . getNumberOfInputGates ( ) ; for ( int i = 0 ; i < numberOfInputGates ; ++ i ) { final ExecutionGate inputGate = vertex . getInputGate ( i ) ; final ChannelType channelType = inputGate . getChannelType ( ) ; final int numberOfInputChannels = inputGate . getNumberOfEdges ( ) ; for ( int j = 0 ; j < numberOfInputChannels ; ++ j ) { final ExecutionEdge inputChannel = inputGate . getEdge ( j ) ; final ExecutionVertex connectedVertex = inputChannel . getOutputGate ( ) . getVertex ( ) ; boolean recurse = false ; if ( ! alreadyVisited . contains ( connectedVertex ) ) { recurse = true ; } if ( channelType == ChannelType . IN_MEMORY && ! pipeline . equals ( connectedVertex . getExecutionPipeline ( ) ) ) { connectedVertex . setExecutionPipeline ( pipeline ) ; recurse = true ; } if ( recurse ) { reconstructExecutionPipeline ( connectedVertex , false , alreadyVisited ) ; } } } } }
Reconstructs the execution pipeline starting at the given vertex by conducting a depth - first search .
40,839
public void check ( Plan plan ) { Preconditions . checkNotNull ( plan , "The passed plan is null." ) ; this . visitedNodes . clear ( ) ; plan . accept ( this ) ; }
Checks whether the given plan is valid . In particular it is checked that all contracts have the correct number of inputs and all inputs are of the expected type . In case of an invalid plan an extended RuntimeException is thrown .
40,840
public boolean preVisit ( Operator < ? > node ) { if ( ! this . visitedNodes . add ( node ) ) { return false ; } if ( node instanceof FileDataSinkBase ) { checkFileDataSink ( ( FileDataSinkBase < ? > ) node ) ; } else if ( node instanceof FileDataSourceBase ) { checkFileDataSource ( ( FileDataSourceBase < ? > ) node ) ; } else if ( node instanceof GenericDataSinkBase ) { checkDataSink ( ( GenericDataSinkBase < ? > ) node ) ; } else if ( node instanceof BulkIterationBase ) { checkBulkIteration ( ( BulkIterationBase < ? > ) node ) ; } else if ( node instanceof SingleInputOperator ) { checkSingleInputContract ( ( SingleInputOperator < ? , ? , ? > ) node ) ; } else if ( node instanceof DualInputOperator < ? , ? , ? , ? > ) { checkDualInputContract ( ( DualInputOperator < ? , ? , ? , ? > ) node ) ; } if ( node instanceof Validatable ) { ( ( Validatable ) node ) . check ( ) ; } return true ; }
Checks whether the node is correctly connected to its input .
40,841
private void checkDataSink ( GenericDataSinkBase < ? > dataSinkContract ) { Operator < ? > input = dataSinkContract . getInput ( ) ; if ( input == null ) { throw new MissingChildException ( ) ; } }
Checks if DataSinkContract is correctly connected . In case that the contract is incorrectly connected a RuntimeException is thrown .
40,842
private void checkFileDataSink ( FileDataSinkBase < ? > fileSink ) { String path = fileSink . getFilePath ( ) ; if ( path == null ) { throw new InvalidProgramException ( "File path of FileDataSink is null." ) ; } if ( path . length ( ) == 0 ) { throw new InvalidProgramException ( "File path of FileDataSink is empty string." ) ; } try { Path p = new Path ( path ) ; String scheme = p . toUri ( ) . getScheme ( ) ; if ( scheme == null ) { throw new InvalidProgramException ( "File path \"" + path + "\" of FileDataSink has no file system scheme (like 'file:// or hdfs://')." ) ; } } catch ( Exception e ) { throw new InvalidProgramException ( "File path \"" + path + "\" of FileDataSink is an invalid path: " + e . getMessage ( ) ) ; } checkDataSink ( fileSink ) ; }
Checks if FileDataSink is correctly connected . In case that the contract is incorrectly connected a RuntimeException is thrown .
40,843
private void checkFileDataSource ( FileDataSourceBase < ? > fileSource ) { String path = fileSource . getFilePath ( ) ; if ( path == null ) { throw new InvalidProgramException ( "File path of FileDataSource is null." ) ; } if ( path . length ( ) == 0 ) { throw new InvalidProgramException ( "File path of FileDataSource is empty string." ) ; } try { Path p = new Path ( path ) ; String scheme = p . toUri ( ) . getScheme ( ) ; if ( scheme == null ) { throw new InvalidProgramException ( "File path \"" + path + "\" of FileDataSource has no file system scheme (like 'file:// or hdfs://')." ) ; } } catch ( Exception e ) { throw new InvalidProgramException ( "File path \"" + path + "\" of FileDataSource is an invalid path: " + e . getMessage ( ) ) ; } }
Checks if FileDataSource is correctly connected . In case that the contract is incorrectly connected a RuntimeException is thrown .
40,844
private void checkSingleInputContract ( SingleInputOperator < ? , ? , ? > singleInputContract ) { Operator < ? > input = singleInputContract . getInput ( ) ; if ( input == null ) { throw new MissingChildException ( ) ; } }
Checks whether a SingleInputOperator is correctly connected . In case that the contract is incorrectly connected a RuntimeException is thrown .
40,845
private void checkDualInputContract ( DualInputOperator < ? , ? , ? , ? > dualInputContract ) { Operator < ? > input1 = dualInputContract . getFirstInput ( ) ; Operator < ? > input2 = dualInputContract . getSecondInput ( ) ; if ( input1 == null || input2 == null ) { throw new MissingChildException ( ) ; } }
Checks whether a DualInputOperator is correctly connected . In case that the contract is incorrectly connected a RuntimeException is thrown .
40,846
public O setParallelism ( int dop ) { if ( dop < 1 ) { throw new IllegalArgumentException ( "The parallelism of an operator must be at least 1." ) ; } this . dop = dop ; @ SuppressWarnings ( "unchecked" ) O returnType = ( O ) this ; return returnType ; }
Sets the degree of parallelism for this operator . The degree must be 1 or more .
40,847
public static < T > Operator < T > createUnionCascade ( Operator < T > input1 , Operator < T > ... input2 ) { if ( input2 == null || input2 . length == 0 ) { return input1 ; } else if ( input2 . length == 1 && input1 == null ) { return input2 [ 0 ] ; } TypeInformation < T > type = null ; if ( input1 != null ) { type = input1 . getOperatorInfo ( ) . getOutputType ( ) ; } else if ( input2 . length > 0 && input2 [ 0 ] != null ) { type = input2 [ 0 ] . getOperatorInfo ( ) . getOutputType ( ) ; } else { throw new IllegalArgumentException ( "Could not determine type information from inputs." ) ; } Union < T > lastUnion = new Union < T > ( new BinaryOperatorInformation < T , T , T > ( type , type , type ) ) ; int i ; if ( input2 [ 0 ] == null ) { throw new IllegalArgumentException ( "The input may not contain null elements." ) ; } lastUnion . setFirstInput ( input2 [ 0 ] ) ; if ( input1 != null ) { lastUnion . setSecondInput ( input1 ) ; i = 1 ; } else { if ( input2 [ 1 ] == null ) { throw new IllegalArgumentException ( "The input may not contain null elements." ) ; } lastUnion . setSecondInput ( input2 [ 1 ] ) ; i = 2 ; } for ( ; i < input2 . length ; i ++ ) { Union < T > tmpUnion = new Union < T > ( new BinaryOperatorInformation < T , T , T > ( type , type , type ) ) ; tmpUnion . setSecondInput ( lastUnion ) ; if ( input2 [ i ] == null ) { throw new IllegalArgumentException ( "The input may not contain null elements." ) ; } tmpUnion . setFirstInput ( input2 [ i ] ) ; lastUnion = tmpUnion ; } return lastUnion ; }
Takes a single Operator and a list of operators and creates a cascade of unions of this inputs if needed . If not needed there was only one operator as input then this operator is returned .
40,848
protected boolean acceptFile ( FileStatus fileStatus ) { final String name = fileStatus . getPath ( ) . getName ( ) ; return ! name . startsWith ( "_" ) && ! name . startsWith ( "." ) ; }
A simple hook to filter files and directories from the input . The method may be overridden . Hadoop s FileInputFormat has a similar mechanism and applies the same filters by default .
40,849
public void append ( final byte [ ] data , final int start , final int len ) { final int oldLength = this . bytes . length ; setCapacity ( this . bytes . length + len , true ) ; System . arraycopy ( data , start , this . bytes , oldLength , len ) ; }
Append a range of bytes to the end of the given data .
40,850
public static boolean isNonStaticInnerClass ( Class < ? > clazz ) { if ( clazz . getEnclosingClass ( ) == null ) { return false ; } else { if ( clazz . getDeclaringClass ( ) != null ) { return ! Modifier . isStatic ( clazz . getModifiers ( ) ) ; } else { return true ; } } }
Checks whether the class is an inner class that is not statically accessible . That is especially true for anonymous inner classes .
40,851
public ManagementGroupVertex getGroupVertex ( final int index ) { if ( index < this . groupVertices . size ( ) ) { return this . groupVertices . get ( index ) ; } return null ; }
Returns the management group vertex with the given index .
40,852
void addGroupVertex ( final ManagementGroupVertex groupVertex ) { this . groupVertices . add ( groupVertex ) ; this . managementGraph . addGroupVertex ( groupVertex . getID ( ) , groupVertex ) ; }
Adds the given group vertex to this management stage .
40,853
void collectGroupVertices ( final List < ManagementGroupVertex > groupVertices ) { final Iterator < ManagementGroupVertex > it = this . groupVertices . iterator ( ) ; while ( it . hasNext ( ) ) { groupVertices . add ( it . next ( ) ) ; } }
Adds all management group vertices contained in this stage to the given list .
40,854
void collectVertices ( final List < ManagementVertex > vertices ) { final Iterator < ManagementGroupVertex > it = this . groupVertices . iterator ( ) ; while ( it . hasNext ( ) ) { it . next ( ) . collectVertices ( vertices ) ; } }
Adds all management vertices contained in this stage s group vertices to the given list .
40,855
public int getNumberOfInputManagementVertices ( ) { int retVal = 0 ; final Iterator < ManagementGroupVertex > it = this . groupVertices . iterator ( ) ; while ( it . hasNext ( ) ) { final ManagementGroupVertex groupVertex = it . next ( ) ; if ( groupVertex . isInputVertex ( ) ) { retVal += groupVertex . getNumberOfGroupMembers ( ) ; } } return retVal ; }
Returns the number of input management vertices in this stage i . e . the number of management vertices which are connected to vertices in a lower stage or have no input channels .
40,856
public int getNumberOfOutputManagementVertices ( ) { int retVal = 0 ; final Iterator < ManagementGroupVertex > it = this . groupVertices . iterator ( ) ; while ( it . hasNext ( ) ) { final ManagementGroupVertex groupVertex = it . next ( ) ; if ( groupVertex . isOutputVertex ( ) ) { retVal += groupVertex . getNumberOfGroupMembers ( ) ; } } return retVal ; }
Returns the number of output management vertices in this stage i . e . the number of management vertices which are connected to vertices in a higher stage or have no output channels .
40,857
public int getNumberOfInputGroupVertices ( ) { int retVal = 0 ; final Iterator < ManagementGroupVertex > it = this . groupVertices . iterator ( ) ; while ( it . hasNext ( ) ) { if ( it . next ( ) . isInputVertex ( ) ) { ++ retVal ; } } return retVal ; }
Returns the number of input group vertices in this stage . Input group vertices are those vertices which have incoming edges from group vertices of a lower stage .
40,858
public ManagementGroupVertex getInputGroupVertex ( int index ) { final Iterator < ManagementGroupVertex > it = this . groupVertices . iterator ( ) ; while ( it . hasNext ( ) ) { final ManagementGroupVertex groupVertex = it . next ( ) ; if ( groupVertex . isInputVertex ( ) ) { if ( index == 0 ) { return groupVertex ; } else { -- index ; } } } return null ; }
Returns the input group vertex in this stage with the given index . Input group vertices are those vertices which have incoming edges from group vertices of a lower stage .
40,859
public int getNumberOfOutputGroupVertices ( ) { int retVal = 0 ; final Iterator < ManagementGroupVertex > it = this . groupVertices . iterator ( ) ; while ( it . hasNext ( ) ) { if ( it . next ( ) . isOutputVertex ( ) ) { ++ retVal ; } } return retVal ; }
Returns the number of output group vertices in this stage . Output group vertices are those vertices which have outgoing edges to group vertices of a higher stage .
40,860
public ManagementGroupVertex getOutputGroupVertex ( int index ) { final Iterator < ManagementGroupVertex > it = this . groupVertices . iterator ( ) ; while ( it . hasNext ( ) ) { final ManagementGroupVertex groupVertex = it . next ( ) ; if ( groupVertex . isOutputVertex ( ) ) { if ( index == 0 ) { return groupVertex ; } else { -- index ; } } } return null ; }
Returns the output group vertex in this stage with the given index . Output group vertices are those vertices which have outgoing edges to group vertices of a higher stage .
40,861
public static HardwareDescription extractFromSystem ( ) { int numberOfCPUCores = Runtime . getRuntime ( ) . availableProcessors ( ) ; long sizeOfPhysicalMemory = getSizeOfPhysicalMemory ( ) ; if ( sizeOfPhysicalMemory < 0 ) { sizeOfPhysicalMemory = 1 ; } long sizeOfFreeMemory = getSizeOfFreeMemory ( ) ; return new HardwareDescription ( numberOfCPUCores , sizeOfPhysicalMemory , sizeOfFreeMemory ) ; }
Extracts a hardware description object from the system .
40,862
private static long getSizeOfFreeMemory ( ) { float fractionToUse = GlobalConfiguration . getFloat ( ConfigConstants . TASK_MANAGER_MEMORY_FRACTION_KEY , ConfigConstants . DEFAULT_MEMORY_MANAGER_MEMORY_FRACTION ) ; Runtime r = Runtime . getRuntime ( ) ; long max = r . maxMemory ( ) ; long total = r . totalMemory ( ) ; long free = r . freeMemory ( ) ; long available = max - total + free ; return ( long ) ( fractionToUse * available ) ; }
Returns the size of free memory in bytes available to the JVM .
40,863
@ SuppressWarnings ( "resource" ) private static long getSizeOfPhysicalMemoryForLinux ( ) { BufferedReader lineReader = null ; try { lineReader = new BufferedReader ( new FileReader ( LINUX_MEMORY_INFO_PATH ) ) ; String line = null ; while ( ( line = lineReader . readLine ( ) ) != null ) { Matcher matcher = LINUX_MEMORY_REGEX . matcher ( line ) ; if ( matcher . matches ( ) ) { String totalMemory = matcher . group ( 1 ) ; return Long . parseLong ( totalMemory ) * 1024L ; } } LOG . error ( "Cannot determine the size of the physical memory using '/proc/meminfo'. Unexpected format." ) ; return - 1 ; } catch ( NumberFormatException e ) { LOG . error ( "Cannot determine the size of the physical memory using '/proc/meminfo'. Unexpected format." ) ; return - 1 ; } catch ( IOException e ) { LOG . error ( "Cannot determine the size of the physical memory using '/proc/meminfo': " + e . getMessage ( ) , e ) ; return - 1 ; } finally { try { if ( lineReader != null ) { lineReader . close ( ) ; } } catch ( Throwable t ) { } } }
Returns the size of the physical memory in bytes on a Linux - based operating system .
40,864
private static long getSizeOfPhysicalMemoryForMac ( ) { BufferedReader bi = null ; try { Process proc = Runtime . getRuntime ( ) . exec ( "sysctl hw.memsize" ) ; bi = new BufferedReader ( new InputStreamReader ( proc . getInputStream ( ) ) ) ; String line ; while ( ( line = bi . readLine ( ) ) != null ) { if ( line . startsWith ( "hw.memsize" ) ) { long memsize = Long . parseLong ( line . split ( ":" ) [ 1 ] . trim ( ) ) ; bi . close ( ) ; proc . destroy ( ) ; return memsize ; } } } catch ( Exception e ) { LOG . error ( e ) ; return - 1 ; } finally { if ( bi != null ) { try { bi . close ( ) ; } catch ( IOException ioe ) { } } } return - 1 ; }
Returns the size of the physical memory in bytes on a Mac OS - based operating system
40,865
void insertForwardEdge ( final ManagementEdge managementEdge , final int index ) { while ( index >= this . forwardEdges . size ( ) ) { this . forwardEdges . add ( null ) ; } this . forwardEdges . set ( index , managementEdge ) ; }
Adds a new edge which originates at this gate .
40,866
void insertBackwardEdge ( final ManagementEdge managementEdge , final int index ) { while ( index >= this . backwardEdges . size ( ) ) { this . backwardEdges . add ( null ) ; } this . backwardEdges . set ( index , managementEdge ) ; }
Adds a new edge which arrives at this gate .
40,867
public ManagementEdge getForwardEdge ( final int index ) { if ( index < this . forwardEdges . size ( ) ) { return this . forwardEdges . get ( index ) ; } return null ; }
Returns the edge originating at the given index .
40,868
public ManagementEdge getBackwardEdge ( final int index ) { if ( index < this . backwardEdges . size ( ) ) { return this . backwardEdges . get ( index ) ; } return null ; }
Returns the edge arriving at the given index .
40,869
private boolean currentGateLeadsToOtherStage ( final TraversalEntry te , final boolean forward ) { final ManagementGroupVertex groupVertex = te . getManagementVertex ( ) . getGroupVertex ( ) ; if ( forward ) { if ( te . getCurrentGate ( ) >= groupVertex . getNumberOfForwardEdges ( ) ) { return false ; } final ManagementGroupEdge edge = groupVertex . getForwardEdge ( te . getCurrentGate ( ) ) ; if ( edge . getTarget ( ) . getStageNumber ( ) == groupVertex . getStageNumber ( ) ) { return false ; } } else { if ( te . getCurrentGate ( ) >= groupVertex . getNumberOfBackwardEdges ( ) ) { return false ; } final ManagementGroupEdge edge = groupVertex . getBackwardEdge ( te . getCurrentGate ( ) ) ; if ( edge . getSource ( ) . getStageNumber ( ) == groupVertex . getStageNumber ( ) ) { return false ; } } return true ; }
Checks if the current gate leads to another stage or not .
40,870
public RequestedLocalProperties filterByNodesConstantSet ( OptimizerNode node , int input ) { if ( this . ordering != null ) { final FieldList involvedIndexes = this . ordering . getInvolvedIndexes ( ) ; for ( int i = 0 ; i < involvedIndexes . size ( ) ; i ++ ) { if ( ! node . isFieldConstant ( input , involvedIndexes . get ( i ) ) ) { return null ; } } } else if ( this . groupedFields != null ) { for ( Integer index : this . groupedFields ) { if ( ! node . isFieldConstant ( input , index ) ) { return null ; } } } return this ; }
Filters these properties by what can be preserved through a user function s constant fields set . Since interesting properties are filtered top - down anything that partially destroys the ordering makes the properties uninteresting .
40,871
public void parameterizeChannel ( Channel channel ) { if ( this . ordering != null ) { channel . setLocalStrategy ( LocalStrategy . SORT , this . ordering . getInvolvedIndexes ( ) , this . ordering . getFieldSortDirections ( ) ) ; } else if ( this . groupedFields != null ) { boolean [ ] dirs = new boolean [ this . groupedFields . size ( ) ] ; Arrays . fill ( dirs , true ) ; channel . setLocalStrategy ( LocalStrategy . SORT , Utils . createOrderedFromSet ( this . groupedFields ) , dirs ) ; } }
Parameterizes the local strategy fields of a channel such that the channel produces the desired local properties .
40,872
public static < T extends Enum < T > > T readEnum ( final DataInput in , final Class < T > enumType ) throws IOException { if ( ! in . readBoolean ( ) ) { return null ; } return T . valueOf ( enumType , StringRecord . readString ( in ) ) ; }
Reads a value from the given enumeration from the specified input stream .
40,873
public static void writeEnum ( final DataOutput out , final Enum < ? > enumVal ) throws IOException { if ( enumVal == null ) { out . writeBoolean ( false ) ; } else { out . writeBoolean ( true ) ; StringRecord . writeString ( out , enumVal . name ( ) ) ; } }
Writes a value of an enumeration to the given output stream .
40,874
public void set ( final byte [ ] utf8 , final int start , final int len ) { setCapacity ( len , false ) ; System . arraycopy ( utf8 , start , bytes , 0 , len ) ; this . length = len ; this . hash = 0 ; }
Set the Text to range of bytes
40,875
private void applyUserDefinedSettings ( final HashMap < AbstractJobVertex , ExecutionGroupVertex > temporaryGroupVertexMap ) throws GraphConversionException { final Iterator < Map . Entry < AbstractJobVertex , ExecutionGroupVertex > > it = temporaryGroupVertexMap . entrySet ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { final Map . Entry < AbstractJobVertex , ExecutionGroupVertex > entry = it . next ( ) ; final AbstractJobVertex jobVertex = entry . getKey ( ) ; if ( jobVertex . getVertexToShareInstancesWith ( ) != null ) { final AbstractJobVertex vertexToShareInstancesWith = jobVertex . getVertexToShareInstancesWith ( ) ; final ExecutionGroupVertex groupVertex = entry . getValue ( ) ; final ExecutionGroupVertex groupVertexToShareInstancesWith = temporaryGroupVertexMap . get ( vertexToShareInstancesWith ) ; groupVertex . shareInstancesWith ( groupVertexToShareInstancesWith ) ; } } Iterator < ExecutionGroupVertex > it2 = new ExecutionGroupVertexIterator ( this , true , - 1 ) ; while ( it2 . hasNext ( ) ) { final ExecutionGroupVertex groupVertex = it2 . next ( ) ; if ( groupVertex . isNumberOfMembersUserDefined ( ) ) { groupVertex . createInitialExecutionVertices ( groupVertex . getUserDefinedNumberOfMembers ( ) ) ; groupVertex . repairSubtasksPerInstance ( ) ; } } it2 = new ExecutionGroupVertexIterator ( this , true , - 1 ) ; while ( it2 . hasNext ( ) ) { final ExecutionGroupVertex groupVertex = it2 . next ( ) ; for ( int i = 0 ; i < groupVertex . getNumberOfForwardLinks ( ) ; i ++ ) { final ExecutionGroupEdge edge = groupVertex . getForwardEdge ( i ) ; if ( edge . isChannelTypeUserDefined ( ) ) { edge . changeChannelType ( edge . getChannelType ( ) ) ; } createExecutionEdgesForGroupEdge ( edge ) ; } } repairInstanceAssignment ( ) ; repairInstanceSharing ( ) ; repairStages ( ) ; }
Applies the user defined settings to the execution graph .
40,876
private void constructExecutionGraph ( final JobGraph jobGraph , final InstanceManager instanceManager ) throws GraphConversionException { final HashMap < AbstractJobVertex , ExecutionVertex > temporaryVertexMap = new HashMap < AbstractJobVertex , ExecutionVertex > ( ) ; final HashMap < AbstractJobVertex , ExecutionGroupVertex > temporaryGroupVertexMap = new HashMap < AbstractJobVertex , ExecutionGroupVertex > ( ) ; final ExecutionStage initialExecutionStage = new ExecutionStage ( this , 0 ) ; this . stages . add ( initialExecutionStage ) ; final AbstractJobVertex [ ] all = jobGraph . getAllJobVertices ( ) ; for ( int i = 0 ; i < all . length ; i ++ ) { final ExecutionVertex createdVertex = createVertex ( all [ i ] , instanceManager , initialExecutionStage , jobGraph . getJobConfiguration ( ) ) ; temporaryVertexMap . put ( all [ i ] , createdVertex ) ; temporaryGroupVertexMap . put ( all [ i ] , createdVertex . getGroupVertex ( ) ) ; } createInitialGroupEdges ( temporaryVertexMap ) ; applyUserDefinedSettings ( temporaryGroupVertexMap ) ; calculateConnectionIDs ( ) ; reconstructExecutionPipelines ( ) ; }
Sets up an execution graph from a job graph .
40,877
private void createInitialGroupEdges ( final HashMap < AbstractJobVertex , ExecutionVertex > vertexMap ) throws GraphConversionException { Iterator < Map . Entry < AbstractJobVertex , ExecutionVertex > > it = vertexMap . entrySet ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { final Map . Entry < AbstractJobVertex , ExecutionVertex > entry = it . next ( ) ; final AbstractJobVertex sjv = entry . getKey ( ) ; final ExecutionVertex sev = entry . getValue ( ) ; final ExecutionGroupVertex sgv = sev . getGroupVertex ( ) ; if ( sjv . getNumberOfForwardConnections ( ) != sgv . getEnvironment ( ) . getNumberOfOutputGates ( ) ) { throw new GraphConversionException ( "Job and execution vertex " + sjv . getName ( ) + " have different number of outputs" ) ; } if ( sjv . getNumberOfBackwardConnections ( ) != sgv . getEnvironment ( ) . getNumberOfInputGates ( ) ) { throw new GraphConversionException ( "Job and execution vertex " + sjv . getName ( ) + " have different number of inputs" ) ; } for ( int i = 0 ; i < sjv . getNumberOfForwardConnections ( ) ; ++ i ) { final JobEdge edge = sjv . getForwardConnection ( i ) ; final AbstractJobVertex tjv = edge . getConnectedVertex ( ) ; final ExecutionVertex tev = vertexMap . get ( tjv ) ; final ExecutionGroupVertex tgv = tev . getGroupVertex ( ) ; ChannelType channelType = edge . getChannelType ( ) ; boolean userDefinedChannelType = true ; if ( channelType == null ) { userDefinedChannelType = false ; channelType = ChannelType . NETWORK ; } final DistributionPattern distributionPattern = edge . getDistributionPattern ( ) ; final ExecutionGroupEdge groupEdge = sgv . wireTo ( tgv , edge . getIndexOfInputGate ( ) , i , channelType , userDefinedChannelType , distributionPattern ) ; final ExecutionGate outputGate = new ExecutionGate ( new GateID ( ) , sev , groupEdge , false ) ; sev . insertOutputGate ( i , outputGate ) ; final ExecutionGate inputGate = new ExecutionGate ( new GateID ( ) , tev , groupEdge , true ) ; tev . insertInputGate ( edge . getIndexOfInputGate ( ) , inputGate ) ; } } }
Creates the initial edges between the group vertices
40,878
public ExecutionVertex getInputVertex ( final int stage , final int index ) { try { final ExecutionStage s = this . stages . get ( stage ) ; if ( s == null ) { return null ; } return s . getInputExecutionVertex ( index ) ; } catch ( ArrayIndexOutOfBoundsException e ) { return null ; } }
Returns the input vertex with the specified index for the given stage
40,879
public ExecutionVertex getVertexByChannelID ( final ChannelID id ) { final ExecutionEdge edge = this . edgeMap . get ( id ) ; if ( edge == null ) { return null ; } if ( id . equals ( edge . getOutputChannelID ( ) ) ) { return edge . getOutputGate ( ) . getVertex ( ) ; } return edge . getInputGate ( ) . getVertex ( ) ; }
Identifies an execution by the specified channel ID and returns it .
40,880
void registerExecutionVertex ( final ExecutionVertex vertex ) { if ( this . vertexMap . put ( vertex . getID ( ) , vertex ) != null ) { throw new IllegalStateException ( "There is already an execution vertex with ID " + vertex . getID ( ) + " registered" ) ; } }
Registers an execution vertex with the execution graph .
40,881
private boolean isCurrentStageCompleted ( ) { if ( this . indexToCurrentExecutionStage >= this . stages . size ( ) ) { return true ; } final ExecutionGraphIterator it = new ExecutionGraphIterator ( this , this . indexToCurrentExecutionStage , true , true ) ; while ( it . hasNext ( ) ) { final ExecutionVertex vertex = it . next ( ) ; if ( vertex . getExecutionState ( ) != ExecutionState . FINISHED ) { return false ; } } return true ; }
Checks if the current execution stage has been successfully completed i . e . all vertices in this stage have successfully finished their execution .
40,882
private void reconstructExecutionPipelines ( ) { final Iterator < ExecutionStage > it = this . stages . iterator ( ) ; while ( it . hasNext ( ) ) { it . next ( ) . reconstructExecutionPipelines ( ) ; } }
Reconstructs the execution pipelines for the entire execution graph .
40,883
private void calculateConnectionIDs ( ) { final Set < ExecutionGroupVertex > alreadyVisited = new HashSet < ExecutionGroupVertex > ( ) ; final ExecutionStage lastStage = getStage ( getNumberOfStages ( ) - 1 ) ; for ( int i = 0 ; i < lastStage . getNumberOfStageMembers ( ) ; ++ i ) { final ExecutionGroupVertex groupVertex = lastStage . getStageMember ( i ) ; int currentConnectionID = 0 ; if ( groupVertex . isOutputVertex ( ) ) { currentConnectionID = groupVertex . calculateConnectionID ( currentConnectionID , alreadyVisited ) ; } } }
Calculates the connection IDs of the graph to avoid deadlocks in the data flow at runtime .
40,884
public void configure ( Configuration parameters ) { this . driverName = parameters . getString ( DRIVER_KEY , null ) ; this . username = parameters . getString ( USERNAME_KEY , null ) ; this . password = parameters . getString ( PASSWORD_KEY , null ) ; this . dbURL = parameters . getString ( URL_KEY , null ) ; this . query = parameters . getString ( QUERY_KEY , null ) ; this . fieldCount = parameters . getInteger ( FIELD_COUNT_KEY , 0 ) ; this . batchInterval = parameters . getInteger ( BATCH_INTERVAL , DEFAULT_BATCH_INTERVERAL ) ; @ SuppressWarnings ( "unchecked" ) Class < Value > [ ] classes = new Class [ this . fieldCount ] ; this . fieldClasses = classes ; for ( int i = 0 ; i < this . fieldCount ; i ++ ) { @ SuppressWarnings ( "unchecked" ) Class < ? extends Value > clazz = ( Class < ? extends Value > ) parameters . getClass ( FIELD_TYPE_KEY + i , null ) ; if ( clazz == null ) { throw new IllegalArgumentException ( "Invalid configuration for JDBCOutputFormat: " + "No type class for parameter " + i ) ; } this . fieldClasses [ i ] = clazz ; } }
Configures this JDBCOutputFormat .
40,885
public void open ( int taskNumber , int numTasks ) throws IOException { try { establishConnection ( ) ; upload = dbConn . prepareStatement ( query ) ; } catch ( SQLException sqe ) { throw new IllegalArgumentException ( "open() failed:\t!" , sqe ) ; } catch ( ClassNotFoundException cnfe ) { throw new IllegalArgumentException ( "JDBC-Class not found:\t" , cnfe ) ; } }
Connects to the target database and initializes the prepared statement .
40,886
public void writeToOutput ( final ChannelWriterOutputView output ) throws IOException { int recordsLeft = this . numRecords ; int currentMemSeg = 0 ; while ( recordsLeft > 0 ) { final MemorySegment currentIndexSegment = this . sortIndex . get ( currentMemSeg ++ ) ; int offset = 0 ; if ( recordsLeft >= this . indexEntriesPerSegment ) { for ( ; offset <= this . lastIndexEntryOffset ; offset += this . indexEntrySize ) { final long pointer = currentIndexSegment . getLong ( offset ) ; this . recordBuffer . setReadPosition ( pointer ) ; this . serializer . copy ( this . recordBuffer , output ) ; } recordsLeft -= this . indexEntriesPerSegment ; } else { for ( ; recordsLeft > 0 ; recordsLeft -- , offset += this . indexEntrySize ) { final long pointer = currentIndexSegment . getLong ( offset ) ; this . recordBuffer . setReadPosition ( pointer ) ; this . serializer . copy ( this . recordBuffer , output ) ; } } } }
Writes the records in this buffer in their logical order to the given output .
40,887
void addInitialSubtask ( final ExecutionVertex ev ) { if ( ev == null ) { throw new IllegalArgumentException ( "Argument ev must not be null" ) ; } if ( this . initialGroupMemberAdded . compareAndSet ( false , true ) ) { this . groupMembers . add ( ev ) ; } }
Adds the initial execution vertex to this group vertex .
40,888
public ExecutionVertex getGroupMember ( final int pos ) { if ( pos < 0 ) { throw new IllegalArgumentException ( "Argument pos must be greater or equal to 0" ) ; } try { return this . groupMembers . get ( pos ) ; } catch ( ArrayIndexOutOfBoundsException e ) { return null ; } }
Returns a specific execution vertex from the list of members .
40,889
ExecutionGroupEdge wireTo ( final ExecutionGroupVertex groupVertex , final int indexOfInputGate , final int indexOfOutputGate , final ChannelType channelType , final boolean userDefinedChannelType , final DistributionPattern distributionPattern ) throws GraphConversionException { try { final ExecutionGroupEdge previousEdge = this . forwardLinks . get ( indexOfOutputGate ) ; if ( previousEdge != null ) { throw new GraphConversionException ( "Output gate " + indexOfOutputGate + " of" + getName ( ) + " already has an outgoing edge" ) ; } } catch ( ArrayIndexOutOfBoundsException e ) { } final ExecutionGroupEdge edge = new ExecutionGroupEdge ( this , indexOfOutputGate , groupVertex , indexOfInputGate , channelType , userDefinedChannelType , distributionPattern ) ; this . forwardLinks . add ( edge ) ; groupVertex . wireBackLink ( edge ) ; return edge ; }
Wires this group vertex to the specified group vertex and creates a back link .
40,890
boolean isWiredTo ( final ExecutionGroupVertex groupVertex ) { final Iterator < ExecutionGroupEdge > it = this . forwardLinks . iterator ( ) ; while ( it . hasNext ( ) ) { final ExecutionGroupEdge edge = it . next ( ) ; if ( edge . getTargetVertex ( ) == groupVertex ) { return true ; } } return false ; }
Checks if this group vertex is wired to the given group vertex .
40,891
void createInitialExecutionVertices ( final int initalNumberOfVertices ) throws GraphConversionException { if ( initalNumberOfVertices == this . getCurrentNumberOfGroupMembers ( ) ) { return ; } if ( this . getCurrentNumberOfGroupMembers ( ) != 1 ) { throw new IllegalStateException ( "This method can only be called for the initial setup of the execution graph" ) ; } if ( this . userDefinedNumberOfMembers != - 1 ) { if ( this . userDefinedNumberOfMembers == getCurrentNumberOfGroupMembers ( ) ) { throw new GraphConversionException ( "Cannot overwrite user defined number of group members" ) ; } } if ( initalNumberOfVertices < this . getMinimumNumberOfGroupMember ( ) ) { throw new GraphConversionException ( "Number of members must be at least " + this . getMinimumNumberOfGroupMember ( ) ) ; } if ( ( this . getMaximumNumberOfGroupMembers ( ) != - 1 ) && ( initalNumberOfVertices > this . getMaximumNumberOfGroupMembers ( ) ) ) { throw new GraphConversionException ( "Number of members cannot exceed " + this . getMaximumNumberOfGroupMembers ( ) ) ; } final ExecutionVertex originalVertex = this . getGroupMember ( 0 ) ; int currentNumberOfExecutionVertices = this . getCurrentNumberOfGroupMembers ( ) ; while ( currentNumberOfExecutionVertices ++ < initalNumberOfVertices ) { final ExecutionVertex vertex = originalVertex . splitVertex ( ) ; vertex . setAllocatedResource ( new AllocatedResource ( DummyInstance . createDummyInstance ( this . instanceType ) , this . instanceType , null ) ) ; this . groupMembers . add ( vertex ) ; } int index = 0 ; final Iterator < ExecutionVertex > it = this . groupMembers . iterator ( ) ; while ( it . hasNext ( ) ) { final ExecutionVertex vertex = it . next ( ) ; vertex . setIndexInVertexGroup ( index ++ ) ; } }
Creates the initial execution vertices managed by this group vertex .
40,892
public void subscribeToEvent ( final EventListener eventListener , final Class < ? extends AbstractTaskEvent > eventType ) { synchronized ( this . subscriptions ) { List < EventListener > subscribers = this . subscriptions . get ( eventType ) ; if ( subscribers == null ) { subscribers = new ArrayList < EventListener > ( ) ; this . subscriptions . put ( eventType , subscribers ) ; } subscribers . add ( eventListener ) ; } }
Subscribes the given event listener object to the specified event type .
40,893
public void deliverEvent ( AbstractTaskEvent event ) { synchronized ( this . subscriptions ) { List < EventListener > subscribers = this . subscriptions . get ( event . getClass ( ) ) ; if ( subscribers == null ) { return ; } final Iterator < EventListener > it = subscribers . iterator ( ) ; while ( it . hasNext ( ) ) { it . next ( ) . eventOccurred ( event ) ; } } }
Delivers a event to all of the registered subscribers .
40,894
void changeChannelType ( final ChannelType newChannelType ) throws GraphConversionException { if ( ! this . channelType . equals ( newChannelType ) && this . userDefinedChannelType ) { throw new GraphConversionException ( "Cannot overwrite user defined channel type" ) ; } this . channelType = newChannelType ; }
Changes the channel type for this edge .
40,895
public void subscribeToEvent ( EventListener eventListener , Class < ? extends AbstractTaskEvent > eventType ) { this . eventHandler . subscribeToEvent ( eventListener , eventType ) ; }
Subscribes the listener object to receive events of the given type .
40,896
public void unsubscribeFromEvent ( EventListener eventListener , Class < ? extends AbstractTaskEvent > eventType ) { this . eventHandler . unsubscribeFromEvent ( eventListener , eventType ) ; }
Removes the subscription for events of the given type for the listener object .
40,897
public static void checkTransition ( boolean jobManager , String taskName , ExecutionState oldState , ExecutionState newState ) { LOG . info ( ( jobManager ? "JM: " : "TM: " ) + "ExecutionState set from " + oldState + " to " + newState + " for task " + taskName ) ; boolean unexpectedStateChange = true ; if ( oldState == ExecutionState . CREATED && newState == ExecutionState . SCHEDULED ) { unexpectedStateChange = false ; } else if ( oldState == ExecutionState . SCHEDULED && newState == ExecutionState . ASSIGNED ) { unexpectedStateChange = false ; } else if ( oldState == ExecutionState . ASSIGNED && newState == ExecutionState . READY ) { unexpectedStateChange = false ; } else if ( oldState == ExecutionState . READY && newState == ExecutionState . STARTING ) { unexpectedStateChange = false ; } else if ( oldState == ExecutionState . STARTING && newState == ExecutionState . RUNNING ) { unexpectedStateChange = false ; } else if ( oldState == ExecutionState . RUNNING && newState == ExecutionState . FINISHING ) { unexpectedStateChange = false ; } else if ( oldState == ExecutionState . FINISHING && newState == ExecutionState . FINISHED ) { unexpectedStateChange = false ; } else if ( oldState == ExecutionState . CREATED && newState == ExecutionState . ASSIGNED ) { unexpectedStateChange = false ; } else if ( oldState == ExecutionState . SCHEDULED && newState == ExecutionState . CANCELING ) { unexpectedStateChange = false ; } else if ( oldState == ExecutionState . ASSIGNED && newState == ExecutionState . CANCELING ) { unexpectedStateChange = false ; } else if ( oldState == ExecutionState . READY && newState == ExecutionState . CANCELING ) { unexpectedStateChange = false ; } else if ( newState == FAILED || newState == CANCELED || newState == CANCELING ) { unexpectedStateChange = false ; } if ( unexpectedStateChange ) { LOG . error ( "Unexpected state change: " + oldState + " -> " + newState ) ; } }
Checks the transition of the execution state and outputs an error in case of an unexpected state transition .
40,898
protected int getFirstFreeOutputGateIndex ( ) { for ( int i = 0 ; i < this . forwardEdges . size ( ) ; i ++ ) { if ( this . forwardEdges . get ( i ) == null ) { return i ; } } return this . forwardEdges . size ( ) ; }
Returns the index of this vertex s first free output gate .
40,899
protected int getFirstFreeInputGateIndex ( ) { for ( int i = 0 ; i < this . backwardEdges . size ( ) ; i ++ ) { if ( this . backwardEdges . get ( i ) == null ) { return i ; } } return this . backwardEdges . size ( ) ; }
Returns the index of this vertex s first free input gate .