idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
43,300
private Matrix < Double > generateRandomMatrix ( final int nRows , final int nColumns ) { final List < List < Double > > rows = new ArrayList <> ( nRows ) ; final Random random = new Random ( ) ; for ( int i = 0 ; i < nRows ; i ++ ) { final List < Double > row = new ArrayList <> ( nColumns ) ; for ( int j = 0 ; j < nCo...
Generate a matrix with random values .
134
8
43,301
private Matrix < Double > generateIdentityMatrix ( final int numDimension ) { final List < List < Double > > rows = new ArrayList <> ( numDimension ) ; for ( int i = 0 ; i < numDimension ; i ++ ) { final List < Double > row = new ArrayList <> ( numDimension ) ; for ( int j = 0 ; j < numDimension ; j ++ ) { final double...
Generate an identity matrix .
127
6
43,302
public Topology getNewInstance ( final Class < ? extends Name < String > > operatorName , final Class < ? extends Topology > topologyClass ) throws InjectionException { final Injector newInjector = injector . forkInjector ( ) ; newInjector . bindVolatileParameter ( OperatorNameClass . class , operatorName ) ; return ne...
Instantiates a new Topology instance .
91
9
43,303
public static void main ( final String [ ] args ) throws InjectionException , IOException { final Configuration partialConfiguration = getEnvironmentConfiguration ( ) ; final Injector injector = Tang . Factory . getTang ( ) . newInjector ( partialConfiguration ) ; final AzureBatchRuntimeConfigurationProvider runtimeCon...
Start the Hello REEF job with the Azure Batch runtime .
164
13
43,304
private void returnResults ( ) { final StringBuilder sb = new StringBuilder ( ) ; for ( final String result : this . results ) { sb . append ( result ) ; } this . results . clear ( ) ; LOG . log ( Level . INFO , "Return results to the client:\n{0}" , sb ) ; httpCallbackHandler . onNext ( CODEC . encode ( sb . toString ...
Construct the final result and forward it to the Client .
95
11
43,305
private synchronized void submit ( final String command ) { LOG . log ( Level . INFO , "Submit command {0} to {1} evaluators. state: {2}" , new Object [ ] { command , this . contexts . size ( ) , this . state } ) ; assert this . state == State . READY ; this . expectCount = this . contexts . size ( ) ; this . state = S...
Submit command to all available evaluators .
128
9
43,306
private synchronized void requestEvaluators ( ) { assert this . state == State . INIT ; LOG . log ( Level . INFO , "Schedule on {0} Evaluators." , this . numEvaluators ) ; this . evaluatorRequestor . newRequest ( ) . setMemory ( 128 ) . setNumberOfCores ( 1 ) . setNumber ( this . numEvaluators ) . submit ( ) ; this . s...
Request the evaluators .
123
6
43,307
private void submit ( final ActiveContext context ) { try { LOG . log ( Level . INFO , "Send task to context: {0}" , new Object [ ] { context } ) ; if ( JobDriver . this . handlerManager . getActiveContextHandler ( ) == 0 ) { throw new RuntimeException ( "Active Context Handler not initialized by CLR." ) ; } final Acti...
Submit a Task to a single Evaluator .
185
10
43,308
private static String readFile ( final String fileName ) throws IOException { return new String ( Files . readAllBytes ( Paths . get ( fileName ) ) , StandardCharsets . UTF_8 ) ; }
read a file and output it as a String .
46
10
43,309
private void writeEvaluatorInfoJsonOutput ( final HttpServletResponse response , final List < String > ids ) throws IOException { try { final EvaluatorInfoSerializer serializer = Tang . Factory . getTang ( ) . newInjector ( ) . getInstance ( EvaluatorInfoSerializer . class ) ; final AvroEvaluatorsInfo evaluatorsInfo = ...
Write Evaluator info as JSON format to HTTP Response .
187
12
43,310
private void writeEvaluatorInfoWebOutput ( final HttpServletResponse response , final List < String > ids ) throws IOException { for ( final String id : ids ) { final EvaluatorDescriptor evaluatorDescriptor = this . reefStateManager . getEvaluators ( ) . get ( id ) ; final PrintWriter writer = response . getWriter ( ) ...
Write Evaluator info on the Response so that to display on web page directly . This is for direct browser queries .
459
24
43,311
private void writeEvaluatorsJsonOutput ( final HttpServletResponse response ) throws IOException { LOG . log ( Level . INFO , "HttpServerReefEventHandler writeEvaluatorsJsonOutput is called" ) ; try { final EvaluatorListSerializer serializer = Tang . Factory . getTang ( ) . newInjector ( ) . getInstance ( EvaluatorList...
Get all evaluator ids and send it back to response as JSON .
233
16
43,312
private void writeEvaluatorsWebOutput ( final HttpServletResponse response ) throws IOException { LOG . log ( Level . INFO , "HttpServerReefEventHandler writeEvaluatorsWebOutput is called" ) ; final PrintWriter writer = response . getWriter ( ) ; writer . println ( "<h1>Evaluators:</h1>" ) ; for ( final Map . Entry < S...
Get all evaluator ids and send it back to response so that can be displayed on web .
296
21
43,313
private void writeDriverJsonInformation ( final HttpServletResponse response ) throws IOException { LOG . log ( Level . INFO , "HttpServerReefEventHandler writeDriverJsonInformation invoked." ) ; try { final DriverInfoSerializer serializer = Tang . Factory . getTang ( ) . newInjector ( ) . getInstance ( DriverInfoSeria...
Write Driver Info as JSON string to Response .
206
9
43,314
private void writeResponse ( final HttpServletResponse response , final String data ) throws IOException { final byte [ ] outputBody = data . getBytes ( StandardCharsets . UTF_8 ) ; response . getOutputStream ( ) . write ( outputBody ) ; }
Write a String to HTTP Response .
58
7
43,315
private void writeDriverWebInformation ( final HttpServletResponse response ) throws IOException { LOG . log ( Level . INFO , "HttpServerReefEventHandler writeDriverWebInformation invoked." ) ; final PrintWriter writer = response . getWriter ( ) ; writer . println ( "<h1>Driver Information:</h1>" ) ; writer . println (...
Get driver information .
260
4
43,316
private void writeLines ( final HttpServletResponse response , final ArrayList < String > lines , final String header ) throws IOException { LOG . log ( Level . INFO , "HttpServerReefEventHandler writeLines is called" ) ; final PrintWriter writer = response . getWriter ( ) ; writer . println ( "<h1>" + header + "</h1>"...
Write lines in ArrayList to the response writer .
121
10
43,317
@ Override public void close ( ) { LOG . log ( Level . FINE , "Closing netty transport socket address: {0}" , this . localAddress ) ; final ChannelGroupFuture clientChannelGroupFuture = this . clientChannelGroup . close ( ) ; final ChannelGroupFuture serverChannelGroupFuture = this . serverChannelGroup . close ( ) ; fi...
Closes all channels and releases all resources .
319
9
43,318
public < T > Link < T > get ( final SocketAddress remoteAddr ) { final LinkReference linkRef = this . addrToLinkRefMap . get ( remoteAddr ) ; return linkRef != null ? ( Link < T > ) linkRef . getLink ( ) : null ; }
Returns a link for the remote address if already cached ; otherwise returns null .
62
15
43,319
@ Override public void registerErrorHandler ( final EventHandler < Exception > handler ) { this . clientEventListener . registerErrorHandler ( handler ) ; this . serverEventListener . registerErrorHandler ( handler ) ; }
Registers the exception event handler .
45
7
43,320
@ SuppressWarnings ( "checkstyle:diamondoperatorforvariabledefinition" ) public AutoCloseable registerHandler ( final RemoteIdentifier sourceIdentifier , final Class < ? extends T > messageType , final EventHandler < ? super T > theHandler ) { final Tuple2 < RemoteIdentifier , Class < ? extends T > > tuple = new Tuple2...
Subscribe for events from a given source and message type .
188
11
43,321
public AutoCloseable registerHandler ( final Class < ? extends T > messageType , final EventHandler < RemoteMessage < ? extends T > > theHandler ) { this . msgTypeToHandlerMap . put ( messageType , theHandler ) ; LOG . log ( Level . FINER , "Add handler for class: {0}" , messageType . getCanonicalName ( ) ) ; return ne...
Subscribe for events of a given message type .
100
9
43,322
public AutoCloseable registerErrorHandler ( final EventHandler < Exception > theHandler ) { this . transport . registerErrorHandler ( theHandler ) ; return new SubscriptionHandler <> ( new Exception ( "Token for finding the error handler subscription" ) , this . unsubscribeException ) ; }
Specify handler for error messages .
60
7
43,323
public void unsubscribe ( final Subscription < T > subscription ) { final T token = subscription . getToken ( ) ; LOG . log ( Level . FINER , "RemoteManager: {0} token {1}" , new Object [ ] { this . name , token } ) ; if ( token instanceof Exception ) { this . transport . registerErrorHandler ( null ) ; } else if ( tok...
Unsubscribes a handler .
159
7
43,324
@ Override @ SuppressWarnings ( "checkstyle:diamondoperatorforvariabledefinition" ) public synchronized void onNext ( final RemoteEvent < byte [ ] > value ) { LOG . log ( Level . FINER , "RemoteManager: {0} value: {1}" , new Object [ ] { this . name , value } ) ; final T decodedEvent = this . codec . decode ( value . g...
Dispatch message received from the remote to proper event handler .
497
11
43,325
public void signal ( ) { if ( lockVar . isHeldByCurrentThread ( ) ) { throw new RuntimeException ( "signal() must not be called on same thread as await()" ) ; } try { lockVar . lock ( ) ; LOG . log ( Level . INFO , "Signalling sleeper..." ) ; isSignal = true ; conditionVar . signal ( ) ; } finally { lockVar . unlock ( ...
Wakes the thread sleeping in (
93
7
43,326
@ Override public < T > EventHandler < T > getHandler ( final RemoteIdentifier destinationIdentifier , final Class < ? extends T > messageType ) { if ( LOG . isLoggable ( Level . FINE ) ) { LOG . log ( Level . FINE , "RemoteManager: {0} destinationIdentifier: {1} messageType: {2}" , new Object [ ] { this . name , desti...
Returns a proxy event handler for a remote identifier and a message type .
150
14
43,327
@ Override public < T , U extends T > AutoCloseable registerHandler ( final Class < U > messageType , final EventHandler < RemoteMessage < T > > theHandler ) { if ( LOG . isLoggable ( Level . FINE ) ) { LOG . log ( Level . FINE , "RemoteManager: {0} messageType: {1} handler: {2}" , new Object [ ] { this . name , messag...
Registers an event handler for a message type and returns a subscription .
139
14
43,328
public void onResourceRequested ( final ResourceRequestEvent resourceRequestEvent , final String containerId , final URI jarFileUri ) { try { createAzureBatchTask ( containerId , jarFileUri ) ; this . outstandingResourceRequests . put ( containerId , resourceRequestEvent ) ; this . outstandingResourceRequestCount . inc...
This method is called when a resource is requested . It will add a task to the existing Azure Batch job which is equivalent to requesting a container in Azure Batch . When the request is fulfilled and the evaluator shim is started it will send a message back to the driver which signals that a resource request was fulfi...
133
66
43,329
@ Override public void onNext ( final RemoteMessage < EvaluatorShimProtocol . EvaluatorShimStatusProto > statusMessage ) { EvaluatorShimProtocol . EvaluatorShimStatusProto message = statusMessage . getMessage ( ) ; String containerId = message . getContainerId ( ) ; String remoteId = message . getRemoteIdentifier ( ) ;...
This method is invoked by the RemoteManager when a message from the evaluator shim is received .
248
21
43,330
public void onClose ( ) { try { this . evaluatorShimCommandChannel . close ( ) ; } catch ( Exception e ) { LOG . log ( Level . WARNING , "An unexpected exception while closing the Evaluator Shim Command channel: {0}" , e ) ; throw new RuntimeException ( e ) ; } }
Closes the evaluator shim remote manager command channel .
69
13
43,331
public URI generateShimJarFile ( ) { try { Set < FileResource > globalFiles = new HashSet <> ( ) ; final File globalFolder = new File ( this . reefFileNames . getGlobalFolderPath ( ) ) ; final File [ ] filesInGlobalFolder = globalFolder . listFiles ( ) ; for ( final File fileEntry : filesInGlobalFolder != null ? filesI...
A utility method which builds the evaluator shim JAR file and uploads it to Azure Storage .
193
22
43,332
private synchronized Path getWritePath ( ) throws IOException { if ( pathToWriteTo == null ) { // If we have not yet written before, check existence of files. final boolean originalExists = fileSystem . exists ( changeLogPath ) ; final boolean altExists = fileSystem . exists ( changeLogAltPath ) ; if ( originalExists &...
Gets the path to write to .
331
8
43,333
@ Override public synchronized void close ( ) throws Exception { if ( this . fileSystem != null && ! this . fsClosed ) { this . fileSystem . close ( ) ; this . fsClosed = true ; } }
Closes the FileSystem .
48
6
43,334
@ Override public byte [ ] call ( final byte [ ] memento ) throws Exception { final ExecutorService schedulerThread = Executors . newSingleThreadExecutor ( ) ; final ExecutorService commandExecutor = Executors . newFixedThreadPool ( numOfThreads ) ; final ConcurrentMap < Integer , Future > futures = new ConcurrentHashM...
Starts the scheduler and executor and waits until termination .
512
13
43,335
@ Override public InetSocketAddress get ( final Identifier key , final Callable < InetSocketAddress > valueFetcher ) throws ExecutionException { return cache . get ( key , valueFetcher ) ; }
Gets an address for an identifier .
47
8
43,336
void onResourceReleaseRequest ( final ResourceReleaseEvent releaseRequest ) { synchronized ( this . theContainers ) { LOG . log ( Level . FINEST , "Release container: {0}" , releaseRequest . getIdentifier ( ) ) ; this . theContainers . release ( releaseRequest . getIdentifier ( ) ) ; this . checkRequestQueue ( ) ; } }
Receives and processes a resource release request .
78
10
43,337
void onResourceLaunchRequest ( final ResourceLaunchEvent launchRequest ) { synchronized ( this . theContainers ) { final Container c = this . theContainers . get ( launchRequest . getIdentifier ( ) ) ; try ( final LoggingScope lb = this . loggingScopeFactory . getNewLoggingScope ( "ResourceManager.onResourceLaunchReque...
Processes a resource launch request .
316
7
43,338
@ Override public Identifier getNewInstance ( final String str ) { final int index = str . indexOf ( "://" ) ; if ( index < 0 ) { throw new RemoteRuntimeException ( "Invalid remote identifier name: " + str ) ; } final String type = str . substring ( 0 , index ) ; final Class < ? extends Identifier > clazz = typeToClazz...
Creates a new remote identifier instance .
263
8
43,339
static Codec < NamingMessage > createLookupCodec ( final IdentifierFactory factory ) { final Map < Class < ? extends NamingMessage > , Codec < ? extends NamingMessage > > clazzToCodecMap = new HashMap <> ( ) ; clazzToCodecMap . put ( NamingLookupRequest . class , new NamingLookupRequestCodec ( factory ) ) ; clazzToCode...
Creates a codec only for lookup .
144
8
43,340
static Codec < NamingMessage > createRegistryCodec ( final IdentifierFactory factory ) { final Map < Class < ? extends NamingMessage > , Codec < ? extends NamingMessage > > clazzToCodecMap = new HashMap <> ( ) ; clazzToCodecMap . put ( NamingRegisterRequest . class , new NamingRegisterRequestCodec ( factory ) ) ; clazz...
Creates a codec only for registration .
179
8
43,341
static Codec < NamingMessage > createFullCodec ( final IdentifierFactory factory ) { final Map < Class < ? extends NamingMessage > , Codec < ? extends NamingMessage > > clazzToCodecMap = new HashMap <> ( ) ; clazzToCodecMap . put ( NamingLookupRequest . class , new NamingLookupRequestCodec ( factory ) ) ; clazzToCodecM...
Creates a codec for both lookup and registration .
238
10
43,342
public void submit ( final Configuration runtimeConfiguration , final String jobName ) throws Exception { final Configuration driverConfiguration = getDriverConfiguration ( jobName ) ; Tang . Factory . getTang ( ) . newInjector ( runtimeConfiguration ) . getInstance ( REEF . class ) . submit ( driverConfiguration ) ; }
Runs BGD on the given runtime .
64
9
43,343
public LauncherStatus run ( final Configuration runtimeConfiguration , final String jobName , final int timeout ) throws Exception { final Configuration driverConfiguration = getDriverConfiguration ( jobName ) ; return DriverLauncher . getLauncher ( runtimeConfiguration ) . run ( driverConfiguration , timeout ) ; }
Runs BGD on the given runtime - with timeout .
57
12
43,344
@ Override public AvroDriverInfo toAvro ( final String id , final String startTime , final List < AvroReefServiceInfo > services ) { return AvroDriverInfo . newBuilder ( ) . setRemoteId ( id ) . setStartTime ( startTime ) . setServices ( services ) . build ( ) ; }
Build AvroDriverInfo object .
71
7
43,345
@ Override public void onNext ( final TransportEvent value ) { LOG . log ( Level . FINEST , "{0}" , value ) ; stage . onNext ( value ) ; }
Handles the received event .
39
6
43,346
@ Override public void onNext ( final T event ) { final EventHandler < T > handler = ( EventHandler < T > ) map . get ( event . getClass ( ) ) ; if ( handler == null ) { throw new WakeRuntimeException ( "No event " + event . getClass ( ) + " handler" ) ; } handler . onNext ( event ) ; }
Invokes a specific handler for the event class type if it exists .
80
14
43,347
@ Override public void close ( ) { LOG . log ( Level . FINE , "EvaluatorIdlenessThreadPool shutdown: begin" ) ; this . executor . shutdown ( ) ; boolean isTerminated = false ; try { isTerminated = this . executor . awaitTermination ( this . waitInMillis , TimeUnit . MILLISECONDS ) ; } catch ( final InterruptedException...
Shutdown the thread pool of idleness checkers .
247
11
43,348
public EvaluatorContext newContext ( final String contextId , final Optional < String > parentID ) { synchronized ( this . priorIds ) { if ( this . priorIds . contains ( contextId ) ) { throw new IllegalStateException ( "Creating second EvaluatorContext instance for id " + contextId ) ; } this . priorIds . add ( contex...
Instantiate a new Context representer with the given id and parent id .
148
15
43,349
public MultiRuntimeDefinitionBuilder addRuntime ( final Configuration config , final String runtimeName ) { Validate . notNull ( config , "runtime configuration module should not be null" ) ; Validate . isTrue ( StringUtils . isNotBlank ( runtimeName ) , "runtimeName should be non empty and non blank string" ) ; final ...
Adds runtime configuration module to the builder .
106
8
43,350
public MultiRuntimeDefinitionBuilder setDefaultRuntimeName ( final String runtimeName ) { Validate . isTrue ( StringUtils . isNotBlank ( runtimeName ) , "runtimeName should be non empty and non blank string" ) ; this . defaultRuntime = runtimeName ; return this ; }
Sets default runtime name .
61
6
43,351
public AvroMultiRuntimeDefinition build ( ) { Validate . isTrue ( this . runtimes . size ( ) == 1 || ! StringUtils . isEmpty ( this . defaultRuntime ) , "Default runtime " + "should be set if more than a single runtime provided" ) ; if ( StringUtils . isEmpty ( this . defaultRuntime ) ) { // we have single runtime conf...
Builds multi runtime definition .
171
6
43,352
void copyTo ( final File destinationFolder ) throws IOException { for ( final File f : this . theFiles ) { final File destinationFile = new File ( destinationFolder , f . getName ( ) ) ; Files . copy ( f . toPath ( ) , destinationFile . toPath ( ) , java . nio . file . StandardCopyOption . REPLACE_EXISTING ) ; } }
Copies all files in the current FileSet to the given destinationFolder .
84
15
43,353
void createSymbolicLinkTo ( final File destinationFolder ) throws IOException { for ( final File f : this . theFiles ) { final File destinationFile = new File ( destinationFolder , f . getName ( ) ) ; Files . createSymbolicLink ( destinationFile . toPath ( ) , f . toPath ( ) ) ; } }
Creates symbolic links for the current FileSet into the given destinationFolder .
74
15
43,354
ConfigurationModule addNamesTo ( final ConfigurationModule input , final OptionalParameter < String > field ) { ConfigurationModule result = input ; for ( final String fileName : this . fileNames ( ) ) { result = result . set ( field , fileName ) ; } return result ; }
Adds the file names of this FileSet to the given field of the given ConfigurationModule .
58
18
43,355
@ Override public AvroEvaluatorList toAvro ( final Map < String , EvaluatorDescriptor > evaluatorMap , final int totalEvaluators , final String startTime ) { final List < AvroEvaluatorEntry > evaluatorEntities = new ArrayList <> ( ) ; for ( final Map . Entry < String , EvaluatorDescriptor > entry : evaluatorMap . entry...
Build AvroEvaluatorList object .
238
10
43,356
@ Override public T decode ( final byte [ ] data ) { final WakeTuplePBuf tuple ; try { tuple = WakeTuplePBuf . parseFrom ( data ) ; } catch ( final InvalidProtocolBufferException e ) { e . printStackTrace ( ) ; throw new RemoteRuntimeException ( e ) ; } final String className = tuple . getClassName ( ) ; final byte [ ]...
Decodes byte array .
173
5
43,357
void start ( ) { final ContextStart contextStart = new ContextStartImpl ( this . identifier ) ; for ( final EventHandler < ContextStart > startHandler : this . contextStartHandlers ) { startHandler . onNext ( contextStart ) ; } }
Fires ContextStart to all registered event handlers .
53
10
43,358
void close ( ) { final ContextStop contextStop = new ContextStopImpl ( this . identifier ) ; for ( final EventHandler < ContextStop > stopHandler : this . contextStopHandlers ) { stopHandler . onNext ( contextStop ) ; } }
Fires ContextStop to all registered event handlers .
53
10
43,359
@ Override public MatMulOutput call ( final MatMulInput input ) throws Exception { final int index = input . getIndex ( ) ; final Matrix < Double > leftMatrix = input . getLeftMatrix ( ) ; final Matrix < Double > rightMatrix = input . getRightMatrix ( ) ; final Matrix < Double > result = leftMatrix . multiply ( rightMa...
Computes multiplication of two matrices .
92
8
43,360
public void submitTask ( final String evaluatorConfiguration , final String taskConfiguration ) { final Configuration contextConfiguration = ContextConfiguration . CONF . set ( ContextConfiguration . IDENTIFIER , "RootContext_" + this . getId ( ) ) . build ( ) ; final String contextConfigurationString = this . configur...
Submit Task with configuration strings . This method should be called from bridge and the configuration strings are serialized at . Net side .
111
25
43,361
public void submitContext ( final String evaluatorConfiguration , final String contextConfiguration ) { launchWithConfigurationString ( evaluatorConfiguration , contextConfiguration , Optional . < String > empty ( ) , Optional . < String > empty ( ) ) ; }
Submit Context with configuration strings . This method should be called from bridge and the configuration strings are serialized at . Net side .
51
25
43,362
public void submitContextAndService ( final String evaluatorConfiguration , final String contextConfiguration , final String serviceConfiguration ) { launchWithConfigurationString ( evaluatorConfiguration , contextConfiguration , Optional . of ( serviceConfiguration ) , Optional . < String > empty ( ) ) ; }
Submit Context and Service with configuration strings . This method should be called from bridge and the configuration strings are serialized at . Net side .
57
27
43,363
public void submitContextAndTask ( final String evaluatorConfiguration , final String contextConfiguration , final String taskConfiguration ) { this . launchWithConfigurationString ( evaluatorConfiguration , contextConfiguration , Optional . < String > empty ( ) , Optional . of ( taskConfiguration ) ) ; }
Submit Context and Task with configuration strings . This method should be called from bridge and the configuration strings are serialized at . Net side .
59
27
43,364
public void submitContextAndServiceAndTask ( final String evaluatorConfiguration , final String contextConfiguration , final String serviceConfiguration , final String taskConfiguration ) { launchWithConfigurationString ( evaluatorConfiguration , contextConfiguration , Optional . of ( serviceConfiguration ) , Optional ...
Submit Context and Service with configuration strings . This method should be called from bridge and the configuration strings are serialized at . Net side
63
26
43,365
private void launchWithConfigurationString ( final String evaluatorConfiguration , final String contextConfiguration , final Optional < String > serviceConfiguration , final Optional < String > taskConfiguration ) { try ( final LoggingScope lb = loggingScopeFactory . evaluatorLaunch ( this . getId ( ) ) ) { final Confi...
Submit Context Service and Task with configuration strings . This method should be called from bridge and the configuration strings are serialized at . Net side
115
27
43,366
private Configuration makeEvaluatorConfiguration ( final Configuration contextConfiguration , final Optional < Configuration > serviceConfiguration , final Optional < Configuration > taskConfiguration ) { final String contextConfigurationString = this . configurationSerializer . toString ( contextConfiguration ) ; fina...
Make configuration for evaluator .
239
7
43,367
private Configuration makeEvaluatorConfiguration ( final String contextConfiguration , final Optional < String > evaluatorConfiguration , final Optional < String > serviceConfiguration , final Optional < String > taskConfiguration ) { final ConfigurationModule evaluatorConfigModule ; if ( this . evaluatorManager . getE...
Make configuration for Evaluator .
524
7
43,368
private Optional < Configuration > makeRootServiceConfiguration ( final Optional < Configuration > serviceConfiguration ) { final EvaluatorType evaluatorType = this . evaluatorManager . getEvaluatorDescriptor ( ) . getProcess ( ) . getType ( ) ; if ( EvaluatorType . CLR == evaluatorType ) { LOG . log ( Level . FINE , "...
Merges the Configurations provided by the evaluatorConfigurationProviders into the given serviceConfiguration if any .
236
22
43,369
public static < T extends Identifier > List < T > parseList ( final String ids , final IdentifierFactory factory ) { final List < T > result = new ArrayList <> ( ) ; for ( final String token : ids . split ( DELIMITER ) ) { result . add ( ( T ) factory . getNewInstance ( token . trim ( ) ) ) ; } return result ; }
Parse a string of multiple IDs .
86
8
43,370
@ Override public Connection < T > newConnection ( final Identifier destId ) { final Connection < T > connection = connectionMap . get ( destId ) ; if ( connection == null ) { final Connection < T > newConnection = new NetworkConnection <> ( this , destId ) ; connectionMap . putIfAbsent ( destId , newConnection ) ; ret...
Creates a new connection .
91
6
43,371
public void start ( ) throws ContextClientCodeException { synchronized ( this . contextStack ) { LOG . log ( Level . FINEST , "Instantiating root context." ) ; this . contextStack . push ( this . launchContext . get ( ) . getRootContext ( ) ) ; if ( this . launchContext . get ( ) . getInitialTaskConfiguration ( ) . isP...
Start the context manager . This initiates the root context .
161
12
43,372
private void addContext ( final EvaluatorRuntimeProtocol . AddContextProto addContextProto ) throws ContextClientCodeException { synchronized ( this . contextStack ) { try { final ContextRuntime currentTopContext = this . contextStack . peek ( ) ; if ( ! currentTopContext . getIdentifier ( ) . equals ( addContextProto ...
Add a context to the stack .
292
7
43,373
private void removeContext ( final String contextID ) { synchronized ( this . contextStack ) { if ( ! contextID . equals ( this . contextStack . peek ( ) . getIdentifier ( ) ) ) { throw new IllegalStateException ( "Trying to close context with id `" + contextID + "`. But the top context has id `" + this . contextStack ...
Remove the context with the given ID from the stack .
272
11
43,374
private void startTask ( final EvaluatorRuntimeProtocol . StartTaskProto startTaskProto ) throws TaskClientCodeException { synchronized ( this . contextStack ) { final ContextRuntime currentActiveContext = this . contextStack . peek ( ) ; final String expectedContextId = startTaskProto . getContextId ( ) ; if ( ! expec...
Launch a Task .
202
4
43,375
public void mark ( final long n ) { tickIfNecessary ( ) ; count . addAndGet ( n ) ; m1Thp . update ( n ) ; m5Thp . update ( n ) ; m15Thp . update ( n ) ; }
Marks the number of events .
58
7
43,376
public double getMeanThp ( ) { if ( getCount ( ) == 0 ) { return 0.0 ; } else { final double elapsed = getTick ( ) - startTime ; return getCount ( ) / elapsed * TimeUnit . SECONDS . toNanos ( 1 ) ; } }
Gets the mean throughput .
65
6
43,377
private Optional < String > getPreferredNode ( final List < String > nodeNames ) { for ( final String nodeName : nodeNames ) { final String possibleRack = this . racksPerNode . get ( nodeName ) ; if ( possibleRack != null && this . freeNodesPerRack . get ( possibleRack ) . containsKey ( nodeName ) ) { return Optional ....
Returns the node name of the container to be allocated if it s available selected from the list of preferred node names . If the list is empty then an empty optional is returned .
99
35
43,378
Optional < Container > allocateContainer ( final ResourceRequestEvent requestEvent ) { Container container = null ; final Optional < String > nodeName = getPreferredNode ( requestEvent . getNodeNameList ( ) ) ; if ( nodeName . isPresent ( ) ) { container = allocateBasedOnNode ( requestEvent . getMemorySize ( ) . orElse...
Allocates a container based on a request event . First it tries to match a given node if it cannot it tries to get a spot in a rack .
221
32
43,379
private < TEvent > void unimplemented ( final long identifier , final TEvent event ) { LOG . log ( Level . SEVERE , "Unimplemented event: [{0}]: {1}" , new Object [ ] { identifier , event } ) ; throw new RuntimeException ( "Event not supported: " + event ) ; }
Called when an event is received that does not have an onNext method definition in TSubCls . Override in TSubClas to handle the error .
73
34
43,380
@ Override public < TEvent > void onNext ( final long identifier , final TEvent event ) throws IllegalAccessException , InvocationTargetException { // Get the reflection method for this call. final Method onNext = methodMap . get ( event . getClass ( ) . getName ( ) ) ; if ( onNext != null ) { // Process the event. onN...
Generic event onNext method in the base interface which maps the call to a concrete event onNext method in TSubCls if one exists otherwise unimplemented is invoked .
110
35
43,381
@ Override public void run ( ) { this . stateLock . lock ( ) ; try { if ( this . state != RunnableProcessState . INIT ) { throw new IllegalStateException ( "The RunnableProcess can't be reused" ) ; } // Setup the stdout and stderr destinations. final File errFile = new File ( folder , standardErrorFileName ) ; final Fi...
Runs the configured process .
509
6
43,382
public void cancel ( ) { this . stateLock . lock ( ) ; try { if ( this . state == RunnableProcessState . RUNNING ) { this . process . destroy ( ) ; if ( ! this . doneCond . await ( DESTROY_WAIT_TIME , TimeUnit . MILLISECONDS ) ) { LOG . log ( Level . FINE , "{0} milliseconds elapsed" , DESTROY_WAIT_TIME ) ; } } if ( th...
Cancels the running process if it is running .
311
11
43,383
private void setState ( final RunnableProcessState newState ) { if ( ! this . state . isLegal ( newState ) ) { throw new IllegalStateException ( "Transition from " + this . state + " to " + newState + " is illegal" ) ; } this . state = newState ; }
Sets a new state for the process .
68
9
43,384
@ Override public void close ( ) { LOG . log ( Level . FINER , "Closing the evaluators - begin" ) ; final List < EvaluatorManager > evaluatorsCopy ; synchronized ( this ) { evaluatorsCopy = new ArrayList <> ( this . evaluators . values ( ) ) ; } for ( final EvaluatorManager evaluatorManager : evaluatorsCopy ) { if ( ! ...
Closes all EvaluatorManager instances managed .
171
10
43,385
public synchronized void put ( final EvaluatorManager evaluatorManager ) { final String evaluatorId = evaluatorManager . getId ( ) ; if ( this . wasClosed ( evaluatorId ) ) { throw new IllegalArgumentException ( "Trying to re-add an Evaluator that has already been closed: " + evaluatorId ) ; } final EvaluatorManager pr...
Adds an EvaluatorManager .
182
7
43,386
public synchronized void removeClosedEvaluator ( final EvaluatorManager evaluatorManager ) { final String evaluatorId = evaluatorManager . getId ( ) ; LOG . log ( Level . FINE , "Removing closed evaluator: {0}" , evaluatorId ) ; if ( ! evaluatorManager . isClosed ( ) ) { throw new IllegalArgumentException ( "Removing e...
Moves evaluator from map of active evaluators to set of closed evaluators .
313
20
43,387
public void submit ( final File clrFolder , final boolean submitDriver , final boolean local , final Configuration clientConfig ) { try ( final LoggingScope ls = this . loggingScopeFactory . driverSubmit ( submitDriver ) ) { if ( ! local ) { this . driverConfiguration = Configurations . merge ( this . driverConfigurati...
Launch the job driver .
266
5
43,388
@ SuppressWarnings ( "checkstyle:hiddenfield" ) public void setDriverInfo ( final String identifier , final int memory , final String jobSubmissionDirectory ) { if ( identifier == null || identifier . isEmpty ( ) ) { throw new RuntimeException ( "driver id cannot be null or empty" ) ; } if ( memory <= 0 ) { throw new R...
Set the driver memory .
179
5
43,389
public void waitForCompletion ( final int waitTime ) { LOG . info ( "Waiting for the Job Driver to complete: " + waitTime ) ; if ( waitTime == 0 ) { close ( 0 ) ; return ; } else if ( waitTime < 0 ) { waitTillDone ( ) ; } final long endTime = System . currentTimeMillis ( ) + waitTime * 1000 ; close ( endTime ) ; }
Wait for the job driver to complete .
92
8
43,390
@ Override public boolean cancel ( final boolean mayInterruptIfRunning ) { try { return cancel ( mayInterruptIfRunning , Optional . < Long > empty ( ) , Optional . < TimeUnit > empty ( ) ) ; } catch ( final TimeoutException e ) { // This should never happen. LOG . log ( Level . WARNING , "Received a TimeoutException in...
Sends a cancel signal and blocks and waits until the task is cancelled completed or failed .
97
18
43,391
public boolean cancel ( final boolean mayInterruptIfRunning , final long timeout , final TimeUnit unit ) throws TimeoutException { return cancel ( mayInterruptIfRunning , Optional . of ( timeout ) , Optional . of ( unit ) ) ; }
Sends a cancel signal and blocks and waits until the task is cancelled completed or failed or if the timeout has expired .
51
24
43,392
@ Override public TOutput get ( ) throws InterruptedException , ExecutionException , CancellationException { countDownLatch . await ( ) ; if ( userResult != null ) { return userResult . get ( ) ; } else { assert this . cancelled . get ( ) || userException != null ; if ( userException != null ) { throw new ExecutionExce...
Infinitely wait for the result of the task .
100
10
43,393
@ Override public TOutput get ( final long timeout , final TimeUnit unit ) throws InterruptedException , ExecutionException , TimeoutException , CancellationException { if ( ! countDownLatch . await ( timeout , unit ) ) { throw new TimeoutException ( "Waiting for the results of the task timed out. Timeout = " + timeout...
Wait a certain period of time for the result of the task .
93
13
43,394
@ Private @ Override public void completed ( final int pTaskletId , final TOutput result ) { assert taskletId == pTaskletId ; this . userResult = Optional . ofNullable ( result ) ; if ( callbackHandler != null ) { executor . execute ( new Runnable ( ) { @ Override public void run ( ) { callbackHandler . onSuccess ( use...
Called by VortexMaster to let the user know that the Tasklet completed .
108
16
43,395
@ Private @ Override public void threwException ( final int pTaskletId , final Exception exception ) { assert taskletId == pTaskletId ; this . userException = exception ; if ( callbackHandler != null ) { executor . execute ( new Runnable ( ) { @ Override public void run ( ) { callbackHandler . onFailure ( exception ) ;...
Called by VortexMaster to let the user know that the Tasklet threw an exception .
95
18
43,396
@ Private @ Override public void cancelled ( final int pTaskletId ) { assert taskletId == pTaskletId ; this . cancelled . set ( true ) ; if ( callbackHandler != null ) { executor . execute ( new Runnable ( ) { @ Override public void run ( ) { callbackHandler . onFailure ( new InterruptedException ( "VortexFuture has be...
Called by VortexMaster to let the user know that the Tasklet was cancelled .
107
17
43,397
private Resource getResource ( final JobSubmissionEvent jobSubmissionEvent ) { return new Resource ( ) . setMemory ( jobSubmissionEvent . getDriverMemory ( ) . get ( ) ) . setvCores ( jobSubmissionEvent . getDriverCPUCores ( ) . get ( ) ) ; }
Extracts the resource demands from the jobSubmissionEvent .
65
13
43,398
private List < String > getCommandList ( final JobSubmissionEvent jobSubmissionEvent ) { return new JavaLaunchCommandBuilder ( ) . setJavaPath ( "%JAVA_HOME%/bin/java" ) . setConfigurationFilePaths ( Collections . singletonList ( this . filenames . getDriverConfigurationPath ( ) ) ) . setClassPath ( this . classpath . ...
Assembles the command to execute the Driver in list form .
194
13
43,399
@ Override public void run ( ) { while ( ! this . closed ) { // Grab the next available message source, if any final EventSource < T > nextSource = sources . poll ( ) ; if ( null != nextSource ) { // Grab the next message from that source, if any final T message = nextSource . getNext ( ) ; if ( null != message ) { // ...
Executes the message loop .
202
6